| File: | build/cod/tests/general.c |
| Warning: | line 87, column 11 Value stored to 'rand2_p' during its initialization is never read |
| 1 | /* This file is generated from general.ops. Do not edit directly. */ |
| 2 | |
| 3 | #include "../config.h" |
| 4 | #include "../cod.h" |
| 5 | #include "stdio.h" |
| 6 | #include "string.h" |
| 7 | #include "math.h" |
| 8 | |
| 9 | #ifdef HAVE_WINDOWS_H |
| 10 | #include <windows.h> |
| 11 | #define srand48(s) srand(s) |
| 12 | #define drand48() (((double)rand())/((double)RAND_MAX)) |
| 13 | #define lrand48() rand() |
| 14 | #define kill(x,y) |
| 15 | #else |
| 16 | extern double drand48(); |
| 17 | extern long lrand48(); |
| 18 | void srand48(long seedval); |
| 19 | #endif |
| 20 | |
| 21 | char* only_run_test = NULL((void*)0); |
| 22 | |
| 23 | static char extern_string[] = "int printf(string format, ...);"; |
| 24 | |
| 25 | static cod_extern_entry externs[2]; |
| 26 | |
| 27 | unsigned long src1ul_vals[9]; |
| 28 | unsigned long src2ul_vals[9]; |
| 29 | unsigned long br_srcul_vals[6]; |
| 30 | unsigned int src1u_vals[9]; |
| 31 | unsigned int src2u_vals[9]; |
| 32 | unsigned int br_srcu_vals[6]; |
| 33 | short src1s_vals[5]; |
| 34 | short src2s_vals[5]; |
| 35 | short br_srcs_vals[6]; |
| 36 | signed char src1c_vals[3]; |
| 37 | signed char src2c_vals[3]; |
| 38 | signed char br_srcc_vals[6]; |
| 39 | unsigned short src1us_vals[5]; |
| 40 | unsigned short src2us_vals[5]; |
| 41 | unsigned short br_srcus_vals[6]; |
| 42 | int src1i_vals[9]; |
| 43 | int src2i_vals[9]; |
| 44 | int br_srci_vals[6]; |
| 45 | char* src1p_vals[2]; |
| 46 | char* src2p_vals[2]; |
| 47 | char* br_srcp_vals[6]; |
| 48 | double src1d_vals[2]; |
| 49 | double src2d_vals[2]; |
| 50 | double br_srcd_vals[6]; |
| 51 | long src1l_vals[9]; |
| 52 | long src2l_vals[9]; |
| 53 | long br_srcl_vals[6]; |
| 54 | unsigned char src1uc_vals[3]; |
| 55 | unsigned char src2uc_vals[3]; |
| 56 | unsigned char br_srcuc_vals[6]; |
| 57 | float src1f_vals[2]; |
| 58 | float src2f_vals[2]; |
| 59 | float br_srcf_vals[6]; |
| 60 | int sh_src2_vals[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32}; |
| 61 | |
| 62 | int sh_src2s_vals[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}; |
| 63 | |
| 64 | int sh_src2c_vals[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8}; |
| 65 | |
| 66 | unsigned long bit_pattern_vals[] = { 0x1, 0x0, 0x2, 0x1, 0x4, 0x3, 0x8, 0x7, 0x10, 0xf, 0x20, 0x1f, 0x40, 0x3f, 0x80, 0x7f, 0x100, 0xff, 0x200, 0x1ff, 0x400, 0x3ff, 0x800, 0x7ff, 0x1000, 0xfff, 0x2000, 0x1fff, 0x4000, 0x3fff, 0x8000, 0x7fff, 0x10000, 0xffff, 0x20000, 0x1ffff, 0x40000, 0x3ffff, 0x80000, 0x7ffff, 0x100000, 0xfffff, 0x200000, 0x1fffff, 0x400000, 0x3fffff, 0x800000, 0x7fffff, 0x1000000, 0xffffff, 0x2000000, 0x1ffffff, 0x4000000, 0x3ffffff, 0x8000000, 0x7ffffff, 0x10000000, 0xfffffff, 0x20000000, 0x1fffffff, 0x40000000, 0x3fffffff, 0x80000000, 0x7fffffff, 0xffffffff}; |
| 67 | |
| 68 | |
| 69 | int failed = 0; |
| 70 | int verbose = 0; |
| 71 | |
| 72 | static void initialize_values() |
| 73 | { |
| 74 | unsigned long rand1_ul = (unsigned long)lrand48(); |
| 75 | unsigned long rand2_ul = (unsigned long)lrand48(); |
| 76 | unsigned int rand1_u = (unsigned int)lrand48(); |
| 77 | unsigned int rand2_u = (unsigned int)lrand48(); |
| 78 | short rand1_s = (short)lrand48(); |
| 79 | short rand2_s = (short)lrand48(); |
| 80 | signed char rand1_c = (signed char)lrand48(); |
| 81 | signed char rand2_c = (signed char)lrand48(); |
| 82 | unsigned short rand1_us = (unsigned short)lrand48(); |
| 83 | unsigned short rand2_us = (unsigned short)lrand48(); |
| 84 | int rand1_i = (int)lrand48(); |
| 85 | int rand2_i = (int)lrand48(); |
| 86 | char* rand1_p = (char*)(char *)lrand48(); |
| 87 | char* rand2_p = (char*)(char *)lrand48(); |
Value stored to 'rand2_p' during its initialization is never read | |
| 88 | double rand1_d = (double)drand48(); |
| 89 | double rand2_d = (double)drand48(); |
| 90 | long rand1_l = (long)lrand48(); |
| 91 | long rand2_l = (long)lrand48(); |
| 92 | unsigned char rand1_uc = (unsigned char)lrand48(); |
| 93 | unsigned char rand2_uc = (unsigned char)lrand48(); |
| 94 | float rand1_f = (float)drand48(); |
| 95 | float rand2_f = (float)drand48(); |
| 96 | while (rand1_f == 0) rand1_f = (float)drand48(); |
| 97 | while (rand2_f == 0) rand2_f = (float)drand48(); |
| 98 | while (rand1_d == 0) rand1_d = (double)drand48(); |
| 99 | while (rand2_d == 0) rand2_d = (double)drand48(); |
| 100 | while (rand1_c == 0) rand1_c = (signed char)lrand48(); |
| 101 | while (rand2_c == 0) rand2_c = (signed char)lrand48(); |
| 102 | while (rand1_s == 0) rand1_s = (short)lrand48(); |
| 103 | while (rand2_s == 0) rand2_s = (short)lrand48(); |
| 104 | while (rand1_i == 0) rand1_i = (int)lrand48(); |
| 105 | while (rand2_i == 0) rand2_i = (int)lrand48(); |
| 106 | while (rand1_l == 0) rand1_l = (long)lrand48(); |
| 107 | while (rand2_l == 0) rand2_l = (long)lrand48(); |
| 108 | while (rand1_uc == 0) rand1_uc = (unsigned char)lrand48(); |
| 109 | while (rand2_uc == 0) rand2_uc = (unsigned char)lrand48(); |
| 110 | while (rand1_us == 0) rand1_us = (unsigned short)lrand48(); |
| 111 | while (rand2_us == 0) rand2_us = (unsigned short)lrand48(); |
| 112 | while (rand1_u == 0) rand1_u = (unsigned int)lrand48(); |
| 113 | while (rand2_u == 0) rand2_u = (unsigned int)lrand48(); |
| 114 | while (rand1_ul == 0) rand1_ul = (unsigned long)lrand48(); |
| 115 | while (rand2_ul == 0) rand2_ul = (unsigned long)lrand48(); |
| 116 | src1f_vals[0] = rand1_f; |
| 117 | src1f_vals[1] = -rand1_f; |
| 118 | src2f_vals[0] = rand2_f; |
| 119 | src2f_vals[1] = -rand2_f; |
| 120 | src1d_vals[0] = rand1_d; |
| 121 | src1d_vals[1] = -rand1_d; |
| 122 | src2d_vals[0] = rand2_d; |
| 123 | src2d_vals[1] = -rand2_d; |
| 124 | src1c_vals[0] = rand1_c; |
| 125 | src1c_vals[1] = -rand1_c; |
| 126 | src1c_vals[2] = rand1_c & 0xf; |
| 127 | src2c_vals[0] = rand2_c; |
| 128 | src2c_vals[1] = -rand2_c; |
| 129 | src2c_vals[2] = rand2_c & 0xf; |
| 130 | src1s_vals[0] = rand1_s; |
| 131 | src1s_vals[1] = -rand1_s; |
| 132 | src1s_vals[2] = rand1_s & 0xf; |
| 133 | src1s_vals[3] = rand1_s & 0xff; |
| 134 | src1s_vals[4] = rand1_s & 0xfff; |
| 135 | src2s_vals[0] = rand2_s; |
| 136 | src2s_vals[1] = -rand2_s; |
| 137 | src2s_vals[2] = rand2_s & 0xf; |
| 138 | src2s_vals[3] = rand2_s & 0xff; |
| 139 | src2s_vals[4] = rand2_s & 0xfff; |
| 140 | src1i_vals[0] = rand1_i; |
| 141 | src1i_vals[1] = -rand1_i; |
| 142 | src1i_vals[2] = rand1_i & 0xf; |
| 143 | src1i_vals[3] = rand1_i & 0xff; |
| 144 | src1i_vals[4] = rand1_i & 0xfff; |
| 145 | src1i_vals[5] = rand1_i & 0xffff; |
| 146 | src1i_vals[6] = rand1_i & 0xfffff; |
| 147 | src1i_vals[7] = rand1_i & 0xffffff; |
| 148 | src1i_vals[8] = rand1_i & 0xfffffff; |
| 149 | src2i_vals[0] = rand2_i; |
| 150 | src2i_vals[1] = -rand2_i; |
| 151 | src2i_vals[2] = rand2_i & 0xf; |
| 152 | src2i_vals[3] = rand2_i & 0xff; |
| 153 | src2i_vals[4] = rand2_i & 0xfff; |
| 154 | src2i_vals[5] = rand2_i & 0xffff; |
| 155 | src2i_vals[6] = rand2_i & 0xfffff; |
| 156 | src2i_vals[7] = rand2_i & 0xffffff; |
| 157 | src2i_vals[8] = rand2_i & 0xfffffff; |
| 158 | src1l_vals[0] = rand1_l; |
| 159 | src1l_vals[1] = -rand1_l; |
| 160 | src1l_vals[2] = rand1_l & 0xf; |
| 161 | src1l_vals[3] = rand1_l & 0xff; |
| 162 | src1l_vals[4] = rand1_l & 0xfff; |
| 163 | src1l_vals[5] = rand1_l & 0xffff; |
| 164 | src1l_vals[6] = rand1_l & 0xfffff; |
| 165 | src1l_vals[7] = rand1_l & 0xffffff; |
| 166 | src1l_vals[8] = rand1_l & 0xfffffff; |
| 167 | src2l_vals[0] = rand2_l; |
| 168 | src2l_vals[1] = -rand2_l; |
| 169 | src2l_vals[2] = rand2_l & 0xf; |
| 170 | src2l_vals[3] = rand2_l & 0xff; |
| 171 | src2l_vals[4] = rand2_l & 0xfff; |
| 172 | src2l_vals[5] = rand2_l & 0xffff; |
| 173 | src2l_vals[6] = rand2_l & 0xfffff; |
| 174 | src2l_vals[7] = rand2_l & 0xffffff; |
| 175 | src2l_vals[8] = rand2_l & 0xfffffff; |
| 176 | src1uc_vals[0] = (unsigned char) rand1_uc; |
| 177 | src1uc_vals[1] = (unsigned char) -(long)rand1_uc; |
| 178 | src1uc_vals[2] = (unsigned char)rand1_uc & 0xf; |
| 179 | src2uc_vals[0] = (unsigned char) rand2_uc; |
| 180 | src2uc_vals[1] = (unsigned char) -(long)rand2_uc; |
| 181 | src2uc_vals[2] = (unsigned char)rand2_uc & 0xf; |
| 182 | src1us_vals[0] = (unsigned short) rand1_us; |
| 183 | src1us_vals[1] = (unsigned short) -(long)rand1_us; |
| 184 | src1us_vals[2] = (unsigned short)rand1_us & 0xf; |
| 185 | src1us_vals[3] = (unsigned short)rand1_us & 0xff; |
| 186 | src1us_vals[4] = (unsigned short)rand1_us & 0xfff; |
| 187 | src2us_vals[0] = (unsigned short) rand2_us; |
| 188 | src2us_vals[1] = (unsigned short) -(long)rand2_us; |
| 189 | src2us_vals[2] = (unsigned short)rand2_us & 0xf; |
| 190 | src2us_vals[3] = (unsigned short)rand2_us & 0xff; |
| 191 | src2us_vals[4] = (unsigned short)rand2_us & 0xfff; |
| 192 | src1u_vals[0] = (unsigned int) rand1_u; |
| 193 | src1u_vals[1] = (unsigned int) -(long)rand1_u; |
| 194 | src1u_vals[2] = (unsigned int)rand1_u & 0xf; |
| 195 | src1u_vals[3] = (unsigned int)rand1_u & 0xff; |
| 196 | src1u_vals[4] = (unsigned int)rand1_u & 0xfff; |
| 197 | src1u_vals[5] = (unsigned int)rand1_u & 0xffff; |
| 198 | src1u_vals[6] = (unsigned int)rand1_u & 0xfffff; |
| 199 | src1u_vals[7] = (unsigned int)rand1_u & 0xffffff; |
| 200 | src1u_vals[8] = (unsigned int)rand1_u & 0xfffffff; |
| 201 | src2u_vals[0] = (unsigned int) rand2_u; |
| 202 | src2u_vals[1] = (unsigned int) -(long)rand2_u; |
| 203 | src2u_vals[2] = (unsigned int)rand2_u & 0xf; |
| 204 | src2u_vals[3] = (unsigned int)rand2_u & 0xff; |
| 205 | src2u_vals[4] = (unsigned int)rand2_u & 0xfff; |
| 206 | src2u_vals[5] = (unsigned int)rand2_u & 0xffff; |
| 207 | src2u_vals[6] = (unsigned int)rand2_u & 0xfffff; |
| 208 | src2u_vals[7] = (unsigned int)rand2_u & 0xffffff; |
| 209 | src2u_vals[8] = (unsigned int)rand2_u & 0xfffffff; |
| 210 | src1ul_vals[0] = (unsigned long) rand1_ul; |
| 211 | src1ul_vals[1] = (unsigned long) -(long)rand1_ul; |
| 212 | src1ul_vals[2] = (unsigned long)rand1_ul & 0xf; |
| 213 | src1ul_vals[3] = (unsigned long)rand1_ul & 0xff; |
| 214 | src1ul_vals[4] = (unsigned long)rand1_ul & 0xfff; |
| 215 | src1ul_vals[5] = (unsigned long)rand1_ul & 0xffff; |
| 216 | src1ul_vals[6] = (unsigned long)rand1_ul & 0xfffff; |
| 217 | src1ul_vals[7] = (unsigned long)rand1_ul & 0xffffff; |
| 218 | src1ul_vals[8] = (unsigned long)rand1_ul & 0xfffffff; |
| 219 | src2ul_vals[0] = (unsigned long) rand2_ul; |
| 220 | src2ul_vals[1] = (unsigned long) -(long)rand2_ul; |
| 221 | src2ul_vals[2] = (unsigned long)rand2_ul & 0xf; |
| 222 | src2ul_vals[3] = (unsigned long)rand2_ul & 0xff; |
| 223 | src2ul_vals[4] = (unsigned long)rand2_ul & 0xfff; |
| 224 | src2ul_vals[5] = (unsigned long)rand2_ul & 0xffff; |
| 225 | src2ul_vals[6] = (unsigned long)rand2_ul & 0xfffff; |
| 226 | src2ul_vals[7] = (unsigned long)rand2_ul & 0xffffff; |
| 227 | src2ul_vals[8] = (unsigned long)rand2_ul & 0xfffffff; |
| 228 | br_srcuc_vals[0] = (unsigned char) rand1_uc; |
| 229 | br_srcuc_vals[1] = (unsigned char) (-(long)rand1_uc); |
| 230 | br_srcuc_vals[2] = (unsigned char) rand1_uc + 1; |
| 231 | br_srcuc_vals[3] = (unsigned char) (-(long)rand1_uc) + 1; |
| 232 | br_srcuc_vals[4] = (unsigned char) rand1_uc - 1; |
| 233 | br_srcuc_vals[5] = (unsigned char) -((long)rand1_uc) - 1; |
| 234 | br_srcus_vals[0] = (unsigned short) rand1_us; |
| 235 | br_srcus_vals[1] = (unsigned short) (-(long)rand1_us); |
| 236 | br_srcus_vals[2] = (unsigned short) rand1_us + 1; |
| 237 | br_srcus_vals[3] = (unsigned short) (-(long)rand1_us) + 1; |
| 238 | br_srcus_vals[4] = (unsigned short) rand1_us - 1; |
| 239 | br_srcus_vals[5] = (unsigned short) -((long)rand1_us) - 1; |
| 240 | br_srcu_vals[0] = (unsigned int) rand1_u; |
| 241 | br_srcu_vals[1] = (unsigned int) (-(long)rand1_u); |
| 242 | br_srcu_vals[2] = (unsigned int) rand1_u + 1; |
| 243 | br_srcu_vals[3] = (unsigned int) (-(long)rand1_u) + 1; |
| 244 | br_srcu_vals[4] = (unsigned int) rand1_u - 1; |
| 245 | br_srcu_vals[5] = (unsigned int) -((long)rand1_u) - 1; |
| 246 | br_srcul_vals[0] = (unsigned long) rand1_ul; |
| 247 | br_srcul_vals[1] = (unsigned long) (-(long)rand1_ul); |
| 248 | br_srcul_vals[2] = (unsigned long) rand1_ul + 1; |
| 249 | br_srcul_vals[3] = (unsigned long) (-(long)rand1_ul) + 1; |
| 250 | br_srcul_vals[4] = (unsigned long) rand1_ul - 1; |
| 251 | br_srcul_vals[5] = (unsigned long) -((long)rand1_ul) - 1; |
| 252 | externs[0].extern_name = "printf"; |
| 253 | externs[0].extern_value = (void*)(long)printf; |
| 254 | externs[1].extern_name = (void*)0; |
| 255 | externs[1].extern_value = (void*)0; |
| 256 | } |
| 257 | void mod_c_tests() |
| 258 | { |
| 259 | if ((only_run_test == NULL((void*)0)) || |
| 260 | (strcmp(only_run_test, "c%c") == 0)) { |
| 261 | int i, j; |
| 262 | static char code[] = "{\n\ |
| 263 | signed char a = p1;\n\ |
| 264 | signed char b = p2;\n\ |
| 265 | return a % b;\n\ |
| 266 | }"; |
| 267 | |
| 268 | signed char (*proc)(signed char a, signed char b); |
| 269 | cod_parse_context context = new_cod_parse_context(); |
| 270 | int dumped = 0; |
| 271 | |
| 272 | cod_code gen_code; |
| 273 | |
| 274 | /* test for signed char % signed char */ |
| 275 | if (verbose) printf("test for signed char %% signed char"); |
| 276 | |
| 277 | cod_assoc_externs(context, externs); |
| 278 | cod_parse_for_context(extern_string, context); |
| 279 | |
| 280 | cod_subroutine_declaration("signed char proc(signed char p1, signed char p2)", |
| 281 | context); |
| 282 | gen_code = cod_code_gen(code, context); |
| 283 | proc = (signed char (*)(signed char, signed char))(long)gen_code->func; |
| 284 | |
| 285 | |
| 286 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 287 | signed char source1_c = src1c_vals[i]; |
| 288 | for (j=0 ; j < sizeof(src2c_vals)/sizeof(src2c_vals[0]) ; j++) { |
| 289 | signed char source2_c = src2c_vals[j]; |
| 290 | |
| 291 | signed char expected_result; |
| 292 | signed char result; |
| 293 | |
| 294 | if (source2_c <= 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip;} |
| 295 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 296 | |
| 297 | expected_result = (signed char) (source1_c % source2_c); |
| 298 | |
| 299 | result = proc(source1_c, source2_c); |
| 300 | if (expected_result != result) { |
| 301 | printf("Failed signed char %% signed char test, expected %d, got %d, for %d %% %d\n", |
| 302 | expected_result, result, source1_c, source2_c); |
| 303 | if (dumped == 0) cod_dump(gen_code); |
| 304 | failed++; |
| 305 | dumped++; |
| 306 | } |
| 307 | skip: ; |
| 308 | } |
| 309 | } |
| 310 | if (verbose) printf(" done\n"); |
| 311 | cod_free_parse_context(context); |
| 312 | cod_code_free(gen_code); |
| 313 | } |
| 314 | if ((only_run_test == NULL((void*)0)) || |
| 315 | (strcmp(only_run_test, "c%uc") == 0)) { |
| 316 | int i, j; |
| 317 | static char code[] = "{\n\ |
| 318 | signed char a = p1;\n\ |
| 319 | unsigned char b = p2;\n\ |
| 320 | return a % b;\n\ |
| 321 | }"; |
| 322 | |
| 323 | signed char (*proc)(signed char a, unsigned char b); |
| 324 | cod_parse_context context = new_cod_parse_context(); |
| 325 | int dumped = 0; |
| 326 | |
| 327 | cod_code gen_code; |
| 328 | |
| 329 | /* test for signed char % unsigned char */ |
| 330 | if (verbose) printf("test for signed char %% unsigned char"); |
| 331 | |
| 332 | cod_assoc_externs(context, externs); |
| 333 | cod_parse_for_context(extern_string, context); |
| 334 | |
| 335 | cod_subroutine_declaration("signed char proc(signed char p1, unsigned char p2)", |
| 336 | context); |
| 337 | gen_code = cod_code_gen(code, context); |
| 338 | proc = (signed char (*)(signed char, unsigned char))(long)gen_code->func; |
| 339 | |
| 340 | |
| 341 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 342 | signed char source1_c = src1c_vals[i]; |
| 343 | for (j=0 ; j < sizeof(src2uc_vals)/sizeof(src2uc_vals[0]) ; j++) { |
| 344 | unsigned char source2_uc = src2uc_vals[j]; |
| 345 | |
| 346 | signed char expected_result; |
| 347 | signed char result; |
| 348 | |
| 349 | if (source2_uc <= 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip1;} |
| 350 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 351 | |
| 352 | expected_result = (signed char) (source1_c % source2_uc); |
| 353 | |
| 354 | result = proc(source1_c, source2_uc); |
| 355 | if (expected_result != result) { |
| 356 | printf("Failed signed char %% unsigned char test, expected %d, got %d, for %d %% %u\n", |
| 357 | expected_result, result, source1_c, source2_uc); |
| 358 | if (dumped == 0) cod_dump(gen_code); |
| 359 | failed++; |
| 360 | dumped++; |
| 361 | } |
| 362 | skip1: ; |
| 363 | } |
| 364 | } |
| 365 | if (verbose) printf(" done\n"); |
| 366 | cod_free_parse_context(context); |
| 367 | cod_code_free(gen_code); |
| 368 | } |
| 369 | if ((only_run_test == NULL((void*)0)) || |
| 370 | (strcmp(only_run_test, "c%s") == 0)) { |
| 371 | int i, j; |
| 372 | static char code[] = "{\n\ |
| 373 | signed char a = p1;\n\ |
| 374 | short b = p2;\n\ |
| 375 | return a % b;\n\ |
| 376 | }"; |
| 377 | |
| 378 | signed char (*proc)(signed char a, short b); |
| 379 | cod_parse_context context = new_cod_parse_context(); |
| 380 | int dumped = 0; |
| 381 | |
| 382 | cod_code gen_code; |
| 383 | |
| 384 | /* test for signed char % short */ |
| 385 | if (verbose) printf("test for signed char %% short"); |
| 386 | |
| 387 | cod_assoc_externs(context, externs); |
| 388 | cod_parse_for_context(extern_string, context); |
| 389 | |
| 390 | cod_subroutine_declaration("signed char proc(signed char p1, short p2)", |
| 391 | context); |
| 392 | gen_code = cod_code_gen(code, context); |
| 393 | proc = (signed char (*)(signed char, short))(long)gen_code->func; |
| 394 | |
| 395 | |
| 396 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 397 | signed char source1_c = src1c_vals[i]; |
| 398 | for (j=0 ; j < sizeof(src2s_vals)/sizeof(src2s_vals[0]) ; j++) { |
| 399 | short source2_s = src2s_vals[j]; |
| 400 | |
| 401 | signed char expected_result; |
| 402 | signed char result; |
| 403 | |
| 404 | if (source2_s <= 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip2;} |
| 405 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 406 | |
| 407 | expected_result = (signed char) (source1_c % source2_s); |
| 408 | |
| 409 | result = proc(source1_c, source2_s); |
| 410 | if (expected_result != result) { |
| 411 | printf("Failed signed char %% short test, expected %d, got %d, for %d %% %d\n", |
| 412 | expected_result, result, source1_c, source2_s); |
| 413 | if (dumped == 0) cod_dump(gen_code); |
| 414 | failed++; |
| 415 | dumped++; |
| 416 | } |
| 417 | skip2: ; |
| 418 | } |
| 419 | } |
| 420 | if (verbose) printf(" done\n"); |
| 421 | cod_free_parse_context(context); |
| 422 | cod_code_free(gen_code); |
| 423 | } |
| 424 | if ((only_run_test == NULL((void*)0)) || |
| 425 | (strcmp(only_run_test, "c%us") == 0)) { |
| 426 | int i, j; |
| 427 | static char code[] = "{\n\ |
| 428 | signed char a = p1;\n\ |
| 429 | unsigned short b = p2;\n\ |
| 430 | return a % b;\n\ |
| 431 | }"; |
| 432 | |
| 433 | signed char (*proc)(signed char a, unsigned short b); |
| 434 | cod_parse_context context = new_cod_parse_context(); |
| 435 | int dumped = 0; |
| 436 | |
| 437 | cod_code gen_code; |
| 438 | |
| 439 | /* test for signed char % unsigned short */ |
| 440 | if (verbose) printf("test for signed char %% unsigned short"); |
| 441 | |
| 442 | cod_assoc_externs(context, externs); |
| 443 | cod_parse_for_context(extern_string, context); |
| 444 | |
| 445 | cod_subroutine_declaration("signed char proc(signed char p1, unsigned short p2)", |
| 446 | context); |
| 447 | gen_code = cod_code_gen(code, context); |
| 448 | proc = (signed char (*)(signed char, unsigned short))(long)gen_code->func; |
| 449 | |
| 450 | |
| 451 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 452 | signed char source1_c = src1c_vals[i]; |
| 453 | for (j=0 ; j < sizeof(src2us_vals)/sizeof(src2us_vals[0]) ; j++) { |
| 454 | unsigned short source2_us = src2us_vals[j]; |
| 455 | |
| 456 | signed char expected_result; |
| 457 | signed char result; |
| 458 | |
| 459 | if (source2_us <= 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip3;} |
| 460 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 461 | |
| 462 | expected_result = (signed char) (source1_c % source2_us); |
| 463 | |
| 464 | result = proc(source1_c, source2_us); |
| 465 | if (expected_result != result) { |
| 466 | printf("Failed signed char %% unsigned short test, expected %d, got %d, for %d %% %u\n", |
| 467 | expected_result, result, source1_c, source2_us); |
| 468 | if (dumped == 0) cod_dump(gen_code); |
| 469 | failed++; |
| 470 | dumped++; |
| 471 | } |
| 472 | skip3: ; |
| 473 | } |
| 474 | } |
| 475 | if (verbose) printf(" done\n"); |
| 476 | cod_free_parse_context(context); |
| 477 | cod_code_free(gen_code); |
| 478 | } |
| 479 | if ((only_run_test == NULL((void*)0)) || |
| 480 | (strcmp(only_run_test, "c%i") == 0)) { |
| 481 | int i, j; |
| 482 | static char code[] = "{\n\ |
| 483 | signed char a = p1;\n\ |
| 484 | int b = p2;\n\ |
| 485 | return a % b;\n\ |
| 486 | }"; |
| 487 | |
| 488 | signed char (*proc)(signed char a, int b); |
| 489 | cod_parse_context context = new_cod_parse_context(); |
| 490 | int dumped = 0; |
| 491 | |
| 492 | cod_code gen_code; |
| 493 | |
| 494 | /* test for signed char % int */ |
| 495 | if (verbose) printf("test for signed char %% int"); |
| 496 | |
| 497 | cod_assoc_externs(context, externs); |
| 498 | cod_parse_for_context(extern_string, context); |
| 499 | |
| 500 | cod_subroutine_declaration("signed char proc(signed char p1, int p2)", |
| 501 | context); |
| 502 | gen_code = cod_code_gen(code, context); |
| 503 | proc = (signed char (*)(signed char, int))(long)gen_code->func; |
| 504 | |
| 505 | |
| 506 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 507 | signed char source1_c = src1c_vals[i]; |
| 508 | for (j=0 ; j < sizeof(src2i_vals)/sizeof(src2i_vals[0]) ; j++) { |
| 509 | int source2_i = src2i_vals[j]; |
| 510 | |
| 511 | signed char expected_result; |
| 512 | signed char result; |
| 513 | |
| 514 | if (source2_i <= 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip4;} |
| 515 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 516 | |
| 517 | expected_result = (signed char) (source1_c % source2_i); |
| 518 | |
| 519 | result = proc(source1_c, source2_i); |
| 520 | if (expected_result != result) { |
| 521 | printf("Failed signed char %% int test, expected %d, got %d, for %d %% %d\n", |
| 522 | expected_result, result, source1_c, source2_i); |
| 523 | if (dumped == 0) cod_dump(gen_code); |
| 524 | failed++; |
| 525 | dumped++; |
| 526 | } |
| 527 | skip4: ; |
| 528 | } |
| 529 | } |
| 530 | if (verbose) printf(" done\n"); |
| 531 | cod_free_parse_context(context); |
| 532 | cod_code_free(gen_code); |
| 533 | } |
| 534 | if ((only_run_test == NULL((void*)0)) || |
| 535 | (strcmp(only_run_test, "c%u") == 0)) { |
| 536 | int i, j; |
| 537 | static char code[] = "{\n\ |
| 538 | signed char a = p1;\n\ |
| 539 | unsigned int b = p2;\n\ |
| 540 | return a % b;\n\ |
| 541 | }"; |
| 542 | |
| 543 | signed char (*proc)(signed char a, unsigned int b); |
| 544 | cod_parse_context context = new_cod_parse_context(); |
| 545 | int dumped = 0; |
| 546 | |
| 547 | cod_code gen_code; |
| 548 | |
| 549 | /* test for signed char % unsigned int */ |
| 550 | if (verbose) printf("test for signed char %% unsigned int"); |
| 551 | |
| 552 | cod_assoc_externs(context, externs); |
| 553 | cod_parse_for_context(extern_string, context); |
| 554 | |
| 555 | cod_subroutine_declaration("signed char proc(signed char p1, unsigned int p2)", |
| 556 | context); |
| 557 | gen_code = cod_code_gen(code, context); |
| 558 | proc = (signed char (*)(signed char, unsigned int))(long)gen_code->func; |
| 559 | |
| 560 | |
| 561 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 562 | signed char source1_c = src1c_vals[i]; |
| 563 | for (j=0 ; j < sizeof(src2u_vals)/sizeof(src2u_vals[0]) ; j++) { |
| 564 | unsigned int source2_u = src2u_vals[j]; |
| 565 | |
| 566 | signed char expected_result; |
| 567 | signed char result; |
| 568 | |
| 569 | if (source2_u <= 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip5;} |
| 570 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 571 | |
| 572 | expected_result = (signed char) (source1_c % source2_u); |
| 573 | |
| 574 | result = proc(source1_c, source2_u); |
| 575 | if (expected_result != result) { |
| 576 | printf("Failed signed char %% unsigned int test, expected %d, got %d, for %d %% %u\n", |
| 577 | expected_result, result, source1_c, source2_u); |
| 578 | if (dumped == 0) cod_dump(gen_code); |
| 579 | failed++; |
| 580 | dumped++; |
| 581 | } |
| 582 | skip5: ; |
| 583 | } |
| 584 | } |
| 585 | if (verbose) printf(" done\n"); |
| 586 | cod_free_parse_context(context); |
| 587 | cod_code_free(gen_code); |
| 588 | } |
| 589 | if ((only_run_test == NULL((void*)0)) || |
| 590 | (strcmp(only_run_test, "c%ul") == 0)) { |
| 591 | int i, j; |
| 592 | static char code[] = "{\n\ |
| 593 | signed char a = p1;\n\ |
| 594 | unsigned long b = p2;\n\ |
| 595 | return a % b;\n\ |
| 596 | }"; |
| 597 | |
| 598 | signed char (*proc)(signed char a, unsigned long b); |
| 599 | cod_parse_context context = new_cod_parse_context(); |
| 600 | int dumped = 0; |
| 601 | |
| 602 | cod_code gen_code; |
| 603 | |
| 604 | /* test for signed char % unsigned long */ |
| 605 | if (verbose) printf("test for signed char %% unsigned long"); |
| 606 | |
| 607 | cod_assoc_externs(context, externs); |
| 608 | cod_parse_for_context(extern_string, context); |
| 609 | |
| 610 | cod_subroutine_declaration("signed char proc(signed char p1, unsigned long p2)", |
| 611 | context); |
| 612 | gen_code = cod_code_gen(code, context); |
| 613 | proc = (signed char (*)(signed char, unsigned long))(long)gen_code->func; |
| 614 | |
| 615 | |
| 616 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 617 | signed char source1_c = src1c_vals[i]; |
| 618 | for (j=0 ; j < sizeof(src2ul_vals)/sizeof(src2ul_vals[0]) ; j++) { |
| 619 | unsigned long source2_ul = src2ul_vals[j]; |
| 620 | |
| 621 | signed char expected_result; |
| 622 | signed char result; |
| 623 | |
| 624 | if (source2_ul <= 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip6;} |
| 625 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 626 | |
| 627 | expected_result = (signed char) (source1_c % source2_ul); |
| 628 | |
| 629 | result = proc(source1_c, source2_ul); |
| 630 | if (expected_result != result) { |
| 631 | printf("Failed signed char %% unsigned long test, expected %d, got %d, for %d %% %lu\n", |
| 632 | expected_result, result, source1_c, source2_ul); |
| 633 | if (dumped == 0) cod_dump(gen_code); |
| 634 | failed++; |
| 635 | dumped++; |
| 636 | } |
| 637 | skip6: ; |
| 638 | } |
| 639 | } |
| 640 | if (verbose) printf(" done\n"); |
| 641 | cod_free_parse_context(context); |
| 642 | cod_code_free(gen_code); |
| 643 | } |
| 644 | if ((only_run_test == NULL((void*)0)) || |
| 645 | (strcmp(only_run_test, "c%l") == 0)) { |
| 646 | int i, j; |
| 647 | static char code[] = "{\n\ |
| 648 | signed char a = p1;\n\ |
| 649 | long b = p2;\n\ |
| 650 | return a % b;\n\ |
| 651 | }"; |
| 652 | |
| 653 | signed char (*proc)(signed char a, long b); |
| 654 | cod_parse_context context = new_cod_parse_context(); |
| 655 | int dumped = 0; |
| 656 | |
| 657 | cod_code gen_code; |
| 658 | |
| 659 | /* test for signed char % long */ |
| 660 | if (verbose) printf("test for signed char %% long"); |
| 661 | |
| 662 | cod_assoc_externs(context, externs); |
| 663 | cod_parse_for_context(extern_string, context); |
| 664 | |
| 665 | cod_subroutine_declaration("signed char proc(signed char p1, long p2)", |
| 666 | context); |
| 667 | gen_code = cod_code_gen(code, context); |
| 668 | proc = (signed char (*)(signed char, long))(long)gen_code->func; |
| 669 | |
| 670 | |
| 671 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 672 | signed char source1_c = src1c_vals[i]; |
| 673 | for (j=0 ; j < sizeof(src2l_vals)/sizeof(src2l_vals[0]) ; j++) { |
| 674 | long source2_l = src2l_vals[j]; |
| 675 | |
| 676 | signed char expected_result; |
| 677 | signed char result; |
| 678 | |
| 679 | if (source2_l <= 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip7;} |
| 680 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 681 | |
| 682 | expected_result = (signed char) (source1_c % source2_l); |
| 683 | |
| 684 | result = proc(source1_c, source2_l); |
| 685 | if (expected_result != result) { |
| 686 | printf("Failed signed char %% long test, expected %d, got %d, for %d %% %ld\n", |
| 687 | expected_result, result, source1_c, source2_l); |
| 688 | if (dumped == 0) cod_dump(gen_code); |
| 689 | failed++; |
| 690 | dumped++; |
| 691 | } |
| 692 | skip7: ; |
| 693 | } |
| 694 | } |
| 695 | if (verbose) printf(" done\n"); |
| 696 | cod_free_parse_context(context); |
| 697 | cod_code_free(gen_code); |
| 698 | } |
| 699 | } |
| 700 | void mod_uc_tests() |
| 701 | { |
| 702 | if ((only_run_test == NULL((void*)0)) || |
| 703 | (strcmp(only_run_test, "uc%c") == 0)) { |
| 704 | int i, j; |
| 705 | static char code[] = "{\n\ |
| 706 | unsigned char a = p1;\n\ |
| 707 | signed char b = p2;\n\ |
| 708 | return a % b;\n\ |
| 709 | }"; |
| 710 | |
| 711 | unsigned char (*proc)(unsigned char a, signed char b); |
| 712 | cod_parse_context context = new_cod_parse_context(); |
| 713 | int dumped = 0; |
| 714 | |
| 715 | cod_code gen_code; |
| 716 | |
| 717 | /* test for unsigned char % signed char */ |
| 718 | if (verbose) printf("test for unsigned char %% signed char"); |
| 719 | |
| 720 | cod_assoc_externs(context, externs); |
| 721 | cod_parse_for_context(extern_string, context); |
| 722 | |
| 723 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, signed char p2)", |
| 724 | context); |
| 725 | gen_code = cod_code_gen(code, context); |
| 726 | proc = (unsigned char (*)(unsigned char, signed char))(long)gen_code->func; |
| 727 | |
| 728 | |
| 729 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 730 | unsigned char source1_uc = src1uc_vals[i]; |
| 731 | for (j=0 ; j < sizeof(src2c_vals)/sizeof(src2c_vals[0]) ; j++) { |
| 732 | signed char source2_c = src2c_vals[j]; |
| 733 | |
| 734 | unsigned char expected_result; |
| 735 | unsigned char result; |
| 736 | |
| 737 | if (source2_c <= 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip8;} |
| 738 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 739 | |
| 740 | expected_result = (unsigned char) (source1_uc % source2_c); |
| 741 | |
| 742 | result = proc(source1_uc, source2_c); |
| 743 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 744 | if (expected_result != result) { |
| 745 | printf("Failed unsigned char %% signed char test, expected %u, got %u, for %u %% %d\n", |
| 746 | expected_result, result, source1_uc, source2_c); |
| 747 | if (dumped == 0) cod_dump(gen_code); |
| 748 | failed++; |
| 749 | dumped++; |
| 750 | } |
| 751 | skip8: ; |
| 752 | } |
| 753 | } |
| 754 | if (verbose) printf(" done\n"); |
| 755 | cod_free_parse_context(context); |
| 756 | cod_code_free(gen_code); |
| 757 | } |
| 758 | if ((only_run_test == NULL((void*)0)) || |
| 759 | (strcmp(only_run_test, "uc%uc") == 0)) { |
| 760 | int i, j; |
| 761 | static char code[] = "{\n\ |
| 762 | unsigned char a = p1;\n\ |
| 763 | unsigned char b = p2;\n\ |
| 764 | return a % b;\n\ |
| 765 | }"; |
| 766 | |
| 767 | unsigned char (*proc)(unsigned char a, unsigned char b); |
| 768 | cod_parse_context context = new_cod_parse_context(); |
| 769 | int dumped = 0; |
| 770 | |
| 771 | cod_code gen_code; |
| 772 | |
| 773 | /* test for unsigned char % unsigned char */ |
| 774 | if (verbose) printf("test for unsigned char %% unsigned char"); |
| 775 | |
| 776 | cod_assoc_externs(context, externs); |
| 777 | cod_parse_for_context(extern_string, context); |
| 778 | |
| 779 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, unsigned char p2)", |
| 780 | context); |
| 781 | gen_code = cod_code_gen(code, context); |
| 782 | proc = (unsigned char (*)(unsigned char, unsigned char))(long)gen_code->func; |
| 783 | |
| 784 | |
| 785 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 786 | unsigned char source1_uc = src1uc_vals[i]; |
| 787 | for (j=0 ; j < sizeof(src2uc_vals)/sizeof(src2uc_vals[0]) ; j++) { |
| 788 | unsigned char source2_uc = src2uc_vals[j]; |
| 789 | |
| 790 | unsigned char expected_result; |
| 791 | unsigned char result; |
| 792 | |
| 793 | if (source2_uc <= 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip9;} |
| 794 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 795 | |
| 796 | expected_result = (unsigned char) (source1_uc % source2_uc); |
| 797 | |
| 798 | result = proc(source1_uc, source2_uc); |
| 799 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 800 | if (expected_result != result) { |
| 801 | printf("Failed unsigned char %% unsigned char test, expected %u, got %u, for %u %% %u\n", |
| 802 | expected_result, result, source1_uc, source2_uc); |
| 803 | if (dumped == 0) cod_dump(gen_code); |
| 804 | failed++; |
| 805 | dumped++; |
| 806 | } |
| 807 | skip9: ; |
| 808 | } |
| 809 | } |
| 810 | if (verbose) printf(" done\n"); |
| 811 | cod_free_parse_context(context); |
| 812 | cod_code_free(gen_code); |
| 813 | } |
| 814 | if ((only_run_test == NULL((void*)0)) || |
| 815 | (strcmp(only_run_test, "uc%s") == 0)) { |
| 816 | int i, j; |
| 817 | static char code[] = "{\n\ |
| 818 | unsigned char a = p1;\n\ |
| 819 | short b = p2;\n\ |
| 820 | return a % b;\n\ |
| 821 | }"; |
| 822 | |
| 823 | unsigned char (*proc)(unsigned char a, short b); |
| 824 | cod_parse_context context = new_cod_parse_context(); |
| 825 | int dumped = 0; |
| 826 | |
| 827 | cod_code gen_code; |
| 828 | |
| 829 | /* test for unsigned char % short */ |
| 830 | if (verbose) printf("test for unsigned char %% short"); |
| 831 | |
| 832 | cod_assoc_externs(context, externs); |
| 833 | cod_parse_for_context(extern_string, context); |
| 834 | |
| 835 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, short p2)", |
| 836 | context); |
| 837 | gen_code = cod_code_gen(code, context); |
| 838 | proc = (unsigned char (*)(unsigned char, short))(long)gen_code->func; |
| 839 | |
| 840 | |
| 841 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 842 | unsigned char source1_uc = src1uc_vals[i]; |
| 843 | for (j=0 ; j < sizeof(src2s_vals)/sizeof(src2s_vals[0]) ; j++) { |
| 844 | short source2_s = src2s_vals[j]; |
| 845 | |
| 846 | unsigned char expected_result; |
| 847 | unsigned char result; |
| 848 | |
| 849 | if (source2_s <= 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip10;} |
| 850 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 851 | |
| 852 | expected_result = (unsigned char) (source1_uc % source2_s); |
| 853 | |
| 854 | result = proc(source1_uc, source2_s); |
| 855 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 856 | if (expected_result != result) { |
| 857 | printf("Failed unsigned char %% short test, expected %u, got %u, for %u %% %d\n", |
| 858 | expected_result, result, source1_uc, source2_s); |
| 859 | if (dumped == 0) cod_dump(gen_code); |
| 860 | failed++; |
| 861 | dumped++; |
| 862 | } |
| 863 | skip10: ; |
| 864 | } |
| 865 | } |
| 866 | if (verbose) printf(" done\n"); |
| 867 | cod_free_parse_context(context); |
| 868 | cod_code_free(gen_code); |
| 869 | } |
| 870 | if ((only_run_test == NULL((void*)0)) || |
| 871 | (strcmp(only_run_test, "uc%us") == 0)) { |
| 872 | int i, j; |
| 873 | static char code[] = "{\n\ |
| 874 | unsigned char a = p1;\n\ |
| 875 | unsigned short b = p2;\n\ |
| 876 | return a % b;\n\ |
| 877 | }"; |
| 878 | |
| 879 | unsigned char (*proc)(unsigned char a, unsigned short b); |
| 880 | cod_parse_context context = new_cod_parse_context(); |
| 881 | int dumped = 0; |
| 882 | |
| 883 | cod_code gen_code; |
| 884 | |
| 885 | /* test for unsigned char % unsigned short */ |
| 886 | if (verbose) printf("test for unsigned char %% unsigned short"); |
| 887 | |
| 888 | cod_assoc_externs(context, externs); |
| 889 | cod_parse_for_context(extern_string, context); |
| 890 | |
| 891 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, unsigned short p2)", |
| 892 | context); |
| 893 | gen_code = cod_code_gen(code, context); |
| 894 | proc = (unsigned char (*)(unsigned char, unsigned short))(long)gen_code->func; |
| 895 | |
| 896 | |
| 897 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 898 | unsigned char source1_uc = src1uc_vals[i]; |
| 899 | for (j=0 ; j < sizeof(src2us_vals)/sizeof(src2us_vals[0]) ; j++) { |
| 900 | unsigned short source2_us = src2us_vals[j]; |
| 901 | |
| 902 | unsigned char expected_result; |
| 903 | unsigned char result; |
| 904 | |
| 905 | if (source2_us <= 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip11;} |
| 906 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 907 | |
| 908 | expected_result = (unsigned char) (source1_uc % source2_us); |
| 909 | |
| 910 | result = proc(source1_uc, source2_us); |
| 911 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 912 | if (expected_result != result) { |
| 913 | printf("Failed unsigned char %% unsigned short test, expected %u, got %u, for %u %% %u\n", |
| 914 | expected_result, result, source1_uc, source2_us); |
| 915 | if (dumped == 0) cod_dump(gen_code); |
| 916 | failed++; |
| 917 | dumped++; |
| 918 | } |
| 919 | skip11: ; |
| 920 | } |
| 921 | } |
| 922 | if (verbose) printf(" done\n"); |
| 923 | cod_free_parse_context(context); |
| 924 | cod_code_free(gen_code); |
| 925 | } |
| 926 | if ((only_run_test == NULL((void*)0)) || |
| 927 | (strcmp(only_run_test, "uc%i") == 0)) { |
| 928 | int i, j; |
| 929 | static char code[] = "{\n\ |
| 930 | unsigned char a = p1;\n\ |
| 931 | int b = p2;\n\ |
| 932 | return a % b;\n\ |
| 933 | }"; |
| 934 | |
| 935 | unsigned char (*proc)(unsigned char a, int b); |
| 936 | cod_parse_context context = new_cod_parse_context(); |
| 937 | int dumped = 0; |
| 938 | |
| 939 | cod_code gen_code; |
| 940 | |
| 941 | /* test for unsigned char % int */ |
| 942 | if (verbose) printf("test for unsigned char %% int"); |
| 943 | |
| 944 | cod_assoc_externs(context, externs); |
| 945 | cod_parse_for_context(extern_string, context); |
| 946 | |
| 947 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, int p2)", |
| 948 | context); |
| 949 | gen_code = cod_code_gen(code, context); |
| 950 | proc = (unsigned char (*)(unsigned char, int))(long)gen_code->func; |
| 951 | |
| 952 | |
| 953 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 954 | unsigned char source1_uc = src1uc_vals[i]; |
| 955 | for (j=0 ; j < sizeof(src2i_vals)/sizeof(src2i_vals[0]) ; j++) { |
| 956 | int source2_i = src2i_vals[j]; |
| 957 | |
| 958 | unsigned char expected_result; |
| 959 | unsigned char result; |
| 960 | |
| 961 | if (source2_i <= 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip12;} |
| 962 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 963 | |
| 964 | expected_result = (unsigned char) (source1_uc % source2_i); |
| 965 | |
| 966 | result = proc(source1_uc, source2_i); |
| 967 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 968 | if (expected_result != result) { |
| 969 | printf("Failed unsigned char %% int test, expected %u, got %u, for %u %% %d\n", |
| 970 | expected_result, result, source1_uc, source2_i); |
| 971 | if (dumped == 0) cod_dump(gen_code); |
| 972 | failed++; |
| 973 | dumped++; |
| 974 | } |
| 975 | skip12: ; |
| 976 | } |
| 977 | } |
| 978 | if (verbose) printf(" done\n"); |
| 979 | cod_free_parse_context(context); |
| 980 | cod_code_free(gen_code); |
| 981 | } |
| 982 | if ((only_run_test == NULL((void*)0)) || |
| 983 | (strcmp(only_run_test, "uc%u") == 0)) { |
| 984 | int i, j; |
| 985 | static char code[] = "{\n\ |
| 986 | unsigned char a = p1;\n\ |
| 987 | unsigned int b = p2;\n\ |
| 988 | return a % b;\n\ |
| 989 | }"; |
| 990 | |
| 991 | unsigned char (*proc)(unsigned char a, unsigned int b); |
| 992 | cod_parse_context context = new_cod_parse_context(); |
| 993 | int dumped = 0; |
| 994 | |
| 995 | cod_code gen_code; |
| 996 | |
| 997 | /* test for unsigned char % unsigned int */ |
| 998 | if (verbose) printf("test for unsigned char %% unsigned int"); |
| 999 | |
| 1000 | cod_assoc_externs(context, externs); |
| 1001 | cod_parse_for_context(extern_string, context); |
| 1002 | |
| 1003 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, unsigned int p2)", |
| 1004 | context); |
| 1005 | gen_code = cod_code_gen(code, context); |
| 1006 | proc = (unsigned char (*)(unsigned char, unsigned int))(long)gen_code->func; |
| 1007 | |
| 1008 | |
| 1009 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 1010 | unsigned char source1_uc = src1uc_vals[i]; |
| 1011 | for (j=0 ; j < sizeof(src2u_vals)/sizeof(src2u_vals[0]) ; j++) { |
| 1012 | unsigned int source2_u = src2u_vals[j]; |
| 1013 | |
| 1014 | unsigned char expected_result; |
| 1015 | unsigned char result; |
| 1016 | |
| 1017 | if (source2_u <= 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip13;} |
| 1018 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 1019 | |
| 1020 | expected_result = (unsigned char) (source1_uc % source2_u); |
| 1021 | |
| 1022 | result = proc(source1_uc, source2_u); |
| 1023 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 1024 | if (expected_result != result) { |
| 1025 | printf("Failed unsigned char %% unsigned int test, expected %u, got %u, for %u %% %u\n", |
| 1026 | expected_result, result, source1_uc, source2_u); |
| 1027 | if (dumped == 0) cod_dump(gen_code); |
| 1028 | failed++; |
| 1029 | dumped++; |
| 1030 | } |
| 1031 | skip13: ; |
| 1032 | } |
| 1033 | } |
| 1034 | if (verbose) printf(" done\n"); |
| 1035 | cod_free_parse_context(context); |
| 1036 | cod_code_free(gen_code); |
| 1037 | } |
| 1038 | if ((only_run_test == NULL((void*)0)) || |
| 1039 | (strcmp(only_run_test, "uc%ul") == 0)) { |
| 1040 | int i, j; |
| 1041 | static char code[] = "{\n\ |
| 1042 | unsigned char a = p1;\n\ |
| 1043 | unsigned long b = p2;\n\ |
| 1044 | return a % b;\n\ |
| 1045 | }"; |
| 1046 | |
| 1047 | unsigned char (*proc)(unsigned char a, unsigned long b); |
| 1048 | cod_parse_context context = new_cod_parse_context(); |
| 1049 | int dumped = 0; |
| 1050 | |
| 1051 | cod_code gen_code; |
| 1052 | |
| 1053 | /* test for unsigned char % unsigned long */ |
| 1054 | if (verbose) printf("test for unsigned char %% unsigned long"); |
| 1055 | |
| 1056 | cod_assoc_externs(context, externs); |
| 1057 | cod_parse_for_context(extern_string, context); |
| 1058 | |
| 1059 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, unsigned long p2)", |
| 1060 | context); |
| 1061 | gen_code = cod_code_gen(code, context); |
| 1062 | proc = (unsigned char (*)(unsigned char, unsigned long))(long)gen_code->func; |
| 1063 | |
| 1064 | |
| 1065 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 1066 | unsigned char source1_uc = src1uc_vals[i]; |
| 1067 | for (j=0 ; j < sizeof(src2ul_vals)/sizeof(src2ul_vals[0]) ; j++) { |
| 1068 | unsigned long source2_ul = src2ul_vals[j]; |
| 1069 | |
| 1070 | unsigned char expected_result; |
| 1071 | unsigned char result; |
| 1072 | |
| 1073 | if (source2_ul <= 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip14;} |
| 1074 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 1075 | |
| 1076 | expected_result = (unsigned char) (source1_uc % source2_ul); |
| 1077 | |
| 1078 | result = proc(source1_uc, source2_ul); |
| 1079 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 1080 | if (expected_result != result) { |
| 1081 | printf("Failed unsigned char %% unsigned long test, expected %u, got %u, for %u %% %lu\n", |
| 1082 | expected_result, result, source1_uc, source2_ul); |
| 1083 | if (dumped == 0) cod_dump(gen_code); |
| 1084 | failed++; |
| 1085 | dumped++; |
| 1086 | } |
| 1087 | skip14: ; |
| 1088 | } |
| 1089 | } |
| 1090 | if (verbose) printf(" done\n"); |
| 1091 | cod_free_parse_context(context); |
| 1092 | cod_code_free(gen_code); |
| 1093 | } |
| 1094 | if ((only_run_test == NULL((void*)0)) || |
| 1095 | (strcmp(only_run_test, "uc%l") == 0)) { |
| 1096 | int i, j; |
| 1097 | static char code[] = "{\n\ |
| 1098 | unsigned char a = p1;\n\ |
| 1099 | long b = p2;\n\ |
| 1100 | return a % b;\n\ |
| 1101 | }"; |
| 1102 | |
| 1103 | unsigned char (*proc)(unsigned char a, long b); |
| 1104 | cod_parse_context context = new_cod_parse_context(); |
| 1105 | int dumped = 0; |
| 1106 | |
| 1107 | cod_code gen_code; |
| 1108 | |
| 1109 | /* test for unsigned char % long */ |
| 1110 | if (verbose) printf("test for unsigned char %% long"); |
| 1111 | |
| 1112 | cod_assoc_externs(context, externs); |
| 1113 | cod_parse_for_context(extern_string, context); |
| 1114 | |
| 1115 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, long p2)", |
| 1116 | context); |
| 1117 | gen_code = cod_code_gen(code, context); |
| 1118 | proc = (unsigned char (*)(unsigned char, long))(long)gen_code->func; |
| 1119 | |
| 1120 | |
| 1121 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 1122 | unsigned char source1_uc = src1uc_vals[i]; |
| 1123 | for (j=0 ; j < sizeof(src2l_vals)/sizeof(src2l_vals[0]) ; j++) { |
| 1124 | long source2_l = src2l_vals[j]; |
| 1125 | |
| 1126 | unsigned char expected_result; |
| 1127 | unsigned char result; |
| 1128 | |
| 1129 | if (source2_l <= 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip15;} |
| 1130 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 1131 | |
| 1132 | expected_result = (unsigned char) (source1_uc % source2_l); |
| 1133 | |
| 1134 | result = proc(source1_uc, source2_l); |
| 1135 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 1136 | if (expected_result != result) { |
| 1137 | printf("Failed unsigned char %% long test, expected %u, got %u, for %u %% %ld\n", |
| 1138 | expected_result, result, source1_uc, source2_l); |
| 1139 | if (dumped == 0) cod_dump(gen_code); |
| 1140 | failed++; |
| 1141 | dumped++; |
| 1142 | } |
| 1143 | skip15: ; |
| 1144 | } |
| 1145 | } |
| 1146 | if (verbose) printf(" done\n"); |
| 1147 | cod_free_parse_context(context); |
| 1148 | cod_code_free(gen_code); |
| 1149 | } |
| 1150 | } |
| 1151 | void mod_s_tests() |
| 1152 | { |
| 1153 | if ((only_run_test == NULL((void*)0)) || |
| 1154 | (strcmp(only_run_test, "s%c") == 0)) { |
| 1155 | int i, j; |
| 1156 | static char code[] = "{\n\ |
| 1157 | short a = p1;\n\ |
| 1158 | signed char b = p2;\n\ |
| 1159 | return a % b;\n\ |
| 1160 | }"; |
| 1161 | |
| 1162 | short (*proc)(short a, signed char b); |
| 1163 | cod_parse_context context = new_cod_parse_context(); |
| 1164 | int dumped = 0; |
| 1165 | |
| 1166 | cod_code gen_code; |
| 1167 | |
| 1168 | /* test for short % signed char */ |
| 1169 | if (verbose) printf("test for short %% signed char"); |
| 1170 | |
| 1171 | cod_assoc_externs(context, externs); |
| 1172 | cod_parse_for_context(extern_string, context); |
| 1173 | |
| 1174 | cod_subroutine_declaration("short proc(short p1, signed char p2)", |
| 1175 | context); |
| 1176 | gen_code = cod_code_gen(code, context); |
| 1177 | proc = (short (*)(short, signed char))(long)gen_code->func; |
| 1178 | |
| 1179 | |
| 1180 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 1181 | short source1_s = src1s_vals[i]; |
| 1182 | for (j=0 ; j < sizeof(src2c_vals)/sizeof(src2c_vals[0]) ; j++) { |
| 1183 | signed char source2_c = src2c_vals[j]; |
| 1184 | |
| 1185 | short expected_result; |
| 1186 | short result; |
| 1187 | |
| 1188 | if (source2_c <= 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip16;} |
| 1189 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 1190 | |
| 1191 | expected_result = (short) (source1_s % source2_c); |
| 1192 | |
| 1193 | result = proc(source1_s, source2_c); |
| 1194 | if (expected_result != result) { |
| 1195 | printf("Failed short %% signed char test, expected %d, got %d, for %d %% %d\n", |
| 1196 | expected_result, result, source1_s, source2_c); |
| 1197 | if (dumped == 0) cod_dump(gen_code); |
| 1198 | failed++; |
| 1199 | dumped++; |
| 1200 | } |
| 1201 | skip16: ; |
| 1202 | } |
| 1203 | } |
| 1204 | if (verbose) printf(" done\n"); |
| 1205 | cod_free_parse_context(context); |
| 1206 | cod_code_free(gen_code); |
| 1207 | } |
| 1208 | if ((only_run_test == NULL((void*)0)) || |
| 1209 | (strcmp(only_run_test, "s%uc") == 0)) { |
| 1210 | int i, j; |
| 1211 | static char code[] = "{\n\ |
| 1212 | short a = p1;\n\ |
| 1213 | unsigned char b = p2;\n\ |
| 1214 | return a % b;\n\ |
| 1215 | }"; |
| 1216 | |
| 1217 | short (*proc)(short a, unsigned char b); |
| 1218 | cod_parse_context context = new_cod_parse_context(); |
| 1219 | int dumped = 0; |
| 1220 | |
| 1221 | cod_code gen_code; |
| 1222 | |
| 1223 | /* test for short % unsigned char */ |
| 1224 | if (verbose) printf("test for short %% unsigned char"); |
| 1225 | |
| 1226 | cod_assoc_externs(context, externs); |
| 1227 | cod_parse_for_context(extern_string, context); |
| 1228 | |
| 1229 | cod_subroutine_declaration("short proc(short p1, unsigned char p2)", |
| 1230 | context); |
| 1231 | gen_code = cod_code_gen(code, context); |
| 1232 | proc = (short (*)(short, unsigned char))(long)gen_code->func; |
| 1233 | |
| 1234 | |
| 1235 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 1236 | short source1_s = src1s_vals[i]; |
| 1237 | for (j=0 ; j < sizeof(src2uc_vals)/sizeof(src2uc_vals[0]) ; j++) { |
| 1238 | unsigned char source2_uc = src2uc_vals[j]; |
| 1239 | |
| 1240 | short expected_result; |
| 1241 | short result; |
| 1242 | |
| 1243 | if (source2_uc <= 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip17;} |
| 1244 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 1245 | |
| 1246 | expected_result = (short) (source1_s % source2_uc); |
| 1247 | |
| 1248 | result = proc(source1_s, source2_uc); |
| 1249 | if (expected_result != result) { |
| 1250 | printf("Failed short %% unsigned char test, expected %d, got %d, for %d %% %u\n", |
| 1251 | expected_result, result, source1_s, source2_uc); |
| 1252 | if (dumped == 0) cod_dump(gen_code); |
| 1253 | failed++; |
| 1254 | dumped++; |
| 1255 | } |
| 1256 | skip17: ; |
| 1257 | } |
| 1258 | } |
| 1259 | if (verbose) printf(" done\n"); |
| 1260 | cod_free_parse_context(context); |
| 1261 | cod_code_free(gen_code); |
| 1262 | } |
| 1263 | if ((only_run_test == NULL((void*)0)) || |
| 1264 | (strcmp(only_run_test, "s%s") == 0)) { |
| 1265 | int i, j; |
| 1266 | static char code[] = "{\n\ |
| 1267 | short a = p1;\n\ |
| 1268 | short b = p2;\n\ |
| 1269 | return a % b;\n\ |
| 1270 | }"; |
| 1271 | |
| 1272 | short (*proc)(short a, short b); |
| 1273 | cod_parse_context context = new_cod_parse_context(); |
| 1274 | int dumped = 0; |
| 1275 | |
| 1276 | cod_code gen_code; |
| 1277 | |
| 1278 | /* test for short % short */ |
| 1279 | if (verbose) printf("test for short %% short"); |
| 1280 | |
| 1281 | cod_assoc_externs(context, externs); |
| 1282 | cod_parse_for_context(extern_string, context); |
| 1283 | |
| 1284 | cod_subroutine_declaration("short proc(short p1, short p2)", |
| 1285 | context); |
| 1286 | gen_code = cod_code_gen(code, context); |
| 1287 | proc = (short (*)(short, short))(long)gen_code->func; |
| 1288 | |
| 1289 | |
| 1290 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 1291 | short source1_s = src1s_vals[i]; |
| 1292 | for (j=0 ; j < sizeof(src2s_vals)/sizeof(src2s_vals[0]) ; j++) { |
| 1293 | short source2_s = src2s_vals[j]; |
| 1294 | |
| 1295 | short expected_result; |
| 1296 | short result; |
| 1297 | |
| 1298 | if (source2_s <= 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip18;} |
| 1299 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 1300 | |
| 1301 | expected_result = (short) (source1_s % source2_s); |
| 1302 | |
| 1303 | result = proc(source1_s, source2_s); |
| 1304 | if (expected_result != result) { |
| 1305 | printf("Failed short %% short test, expected %d, got %d, for %d %% %d\n", |
| 1306 | expected_result, result, source1_s, source2_s); |
| 1307 | if (dumped == 0) cod_dump(gen_code); |
| 1308 | failed++; |
| 1309 | dumped++; |
| 1310 | } |
| 1311 | skip18: ; |
| 1312 | } |
| 1313 | } |
| 1314 | if (verbose) printf(" done\n"); |
| 1315 | cod_free_parse_context(context); |
| 1316 | cod_code_free(gen_code); |
| 1317 | } |
| 1318 | if ((only_run_test == NULL((void*)0)) || |
| 1319 | (strcmp(only_run_test, "s%us") == 0)) { |
| 1320 | int i, j; |
| 1321 | static char code[] = "{\n\ |
| 1322 | short a = p1;\n\ |
| 1323 | unsigned short b = p2;\n\ |
| 1324 | return a % b;\n\ |
| 1325 | }"; |
| 1326 | |
| 1327 | short (*proc)(short a, unsigned short b); |
| 1328 | cod_parse_context context = new_cod_parse_context(); |
| 1329 | int dumped = 0; |
| 1330 | |
| 1331 | cod_code gen_code; |
| 1332 | |
| 1333 | /* test for short % unsigned short */ |
| 1334 | if (verbose) printf("test for short %% unsigned short"); |
| 1335 | |
| 1336 | cod_assoc_externs(context, externs); |
| 1337 | cod_parse_for_context(extern_string, context); |
| 1338 | |
| 1339 | cod_subroutine_declaration("short proc(short p1, unsigned short p2)", |
| 1340 | context); |
| 1341 | gen_code = cod_code_gen(code, context); |
| 1342 | proc = (short (*)(short, unsigned short))(long)gen_code->func; |
| 1343 | |
| 1344 | |
| 1345 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 1346 | short source1_s = src1s_vals[i]; |
| 1347 | for (j=0 ; j < sizeof(src2us_vals)/sizeof(src2us_vals[0]) ; j++) { |
| 1348 | unsigned short source2_us = src2us_vals[j]; |
| 1349 | |
| 1350 | short expected_result; |
| 1351 | short result; |
| 1352 | |
| 1353 | if (source2_us <= 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip19;} |
| 1354 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 1355 | |
| 1356 | expected_result = (short) (source1_s % source2_us); |
| 1357 | |
| 1358 | result = proc(source1_s, source2_us); |
| 1359 | if (expected_result != result) { |
| 1360 | printf("Failed short %% unsigned short test, expected %d, got %d, for %d %% %u\n", |
| 1361 | expected_result, result, source1_s, source2_us); |
| 1362 | if (dumped == 0) cod_dump(gen_code); |
| 1363 | failed++; |
| 1364 | dumped++; |
| 1365 | } |
| 1366 | skip19: ; |
| 1367 | } |
| 1368 | } |
| 1369 | if (verbose) printf(" done\n"); |
| 1370 | cod_free_parse_context(context); |
| 1371 | cod_code_free(gen_code); |
| 1372 | } |
| 1373 | if ((only_run_test == NULL((void*)0)) || |
| 1374 | (strcmp(only_run_test, "s%i") == 0)) { |
| 1375 | int i, j; |
| 1376 | static char code[] = "{\n\ |
| 1377 | short a = p1;\n\ |
| 1378 | int b = p2;\n\ |
| 1379 | return a % b;\n\ |
| 1380 | }"; |
| 1381 | |
| 1382 | short (*proc)(short a, int b); |
| 1383 | cod_parse_context context = new_cod_parse_context(); |
| 1384 | int dumped = 0; |
| 1385 | |
| 1386 | cod_code gen_code; |
| 1387 | |
| 1388 | /* test for short % int */ |
| 1389 | if (verbose) printf("test for short %% int"); |
| 1390 | |
| 1391 | cod_assoc_externs(context, externs); |
| 1392 | cod_parse_for_context(extern_string, context); |
| 1393 | |
| 1394 | cod_subroutine_declaration("short proc(short p1, int p2)", |
| 1395 | context); |
| 1396 | gen_code = cod_code_gen(code, context); |
| 1397 | proc = (short (*)(short, int))(long)gen_code->func; |
| 1398 | |
| 1399 | |
| 1400 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 1401 | short source1_s = src1s_vals[i]; |
| 1402 | for (j=0 ; j < sizeof(src2i_vals)/sizeof(src2i_vals[0]) ; j++) { |
| 1403 | int source2_i = src2i_vals[j]; |
| 1404 | |
| 1405 | short expected_result; |
| 1406 | short result; |
| 1407 | |
| 1408 | if (source2_i <= 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip20;} |
| 1409 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 1410 | |
| 1411 | expected_result = (short) (source1_s % source2_i); |
| 1412 | |
| 1413 | result = proc(source1_s, source2_i); |
| 1414 | if (expected_result != result) { |
| 1415 | printf("Failed short %% int test, expected %d, got %d, for %d %% %d\n", |
| 1416 | expected_result, result, source1_s, source2_i); |
| 1417 | if (dumped == 0) cod_dump(gen_code); |
| 1418 | failed++; |
| 1419 | dumped++; |
| 1420 | } |
| 1421 | skip20: ; |
| 1422 | } |
| 1423 | } |
| 1424 | if (verbose) printf(" done\n"); |
| 1425 | cod_free_parse_context(context); |
| 1426 | cod_code_free(gen_code); |
| 1427 | } |
| 1428 | if ((only_run_test == NULL((void*)0)) || |
| 1429 | (strcmp(only_run_test, "s%u") == 0)) { |
| 1430 | int i, j; |
| 1431 | static char code[] = "{\n\ |
| 1432 | short a = p1;\n\ |
| 1433 | unsigned int b = p2;\n\ |
| 1434 | return a % b;\n\ |
| 1435 | }"; |
| 1436 | |
| 1437 | short (*proc)(short a, unsigned int b); |
| 1438 | cod_parse_context context = new_cod_parse_context(); |
| 1439 | int dumped = 0; |
| 1440 | |
| 1441 | cod_code gen_code; |
| 1442 | |
| 1443 | /* test for short % unsigned int */ |
| 1444 | if (verbose) printf("test for short %% unsigned int"); |
| 1445 | |
| 1446 | cod_assoc_externs(context, externs); |
| 1447 | cod_parse_for_context(extern_string, context); |
| 1448 | |
| 1449 | cod_subroutine_declaration("short proc(short p1, unsigned int p2)", |
| 1450 | context); |
| 1451 | gen_code = cod_code_gen(code, context); |
| 1452 | proc = (short (*)(short, unsigned int))(long)gen_code->func; |
| 1453 | |
| 1454 | |
| 1455 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 1456 | short source1_s = src1s_vals[i]; |
| 1457 | for (j=0 ; j < sizeof(src2u_vals)/sizeof(src2u_vals[0]) ; j++) { |
| 1458 | unsigned int source2_u = src2u_vals[j]; |
| 1459 | |
| 1460 | short expected_result; |
| 1461 | short result; |
| 1462 | |
| 1463 | if (source2_u <= 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip21;} |
| 1464 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 1465 | |
| 1466 | expected_result = (short) (source1_s % source2_u); |
| 1467 | |
| 1468 | result = proc(source1_s, source2_u); |
| 1469 | if (expected_result != result) { |
| 1470 | printf("Failed short %% unsigned int test, expected %d, got %d, for %d %% %u\n", |
| 1471 | expected_result, result, source1_s, source2_u); |
| 1472 | if (dumped == 0) cod_dump(gen_code); |
| 1473 | failed++; |
| 1474 | dumped++; |
| 1475 | } |
| 1476 | skip21: ; |
| 1477 | } |
| 1478 | } |
| 1479 | if (verbose) printf(" done\n"); |
| 1480 | cod_free_parse_context(context); |
| 1481 | cod_code_free(gen_code); |
| 1482 | } |
| 1483 | if ((only_run_test == NULL((void*)0)) || |
| 1484 | (strcmp(only_run_test, "s%ul") == 0)) { |
| 1485 | int i, j; |
| 1486 | static char code[] = "{\n\ |
| 1487 | short a = p1;\n\ |
| 1488 | unsigned long b = p2;\n\ |
| 1489 | return a % b;\n\ |
| 1490 | }"; |
| 1491 | |
| 1492 | short (*proc)(short a, unsigned long b); |
| 1493 | cod_parse_context context = new_cod_parse_context(); |
| 1494 | int dumped = 0; |
| 1495 | |
| 1496 | cod_code gen_code; |
| 1497 | |
| 1498 | /* test for short % unsigned long */ |
| 1499 | if (verbose) printf("test for short %% unsigned long"); |
| 1500 | |
| 1501 | cod_assoc_externs(context, externs); |
| 1502 | cod_parse_for_context(extern_string, context); |
| 1503 | |
| 1504 | cod_subroutine_declaration("short proc(short p1, unsigned long p2)", |
| 1505 | context); |
| 1506 | gen_code = cod_code_gen(code, context); |
| 1507 | proc = (short (*)(short, unsigned long))(long)gen_code->func; |
| 1508 | |
| 1509 | |
| 1510 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 1511 | short source1_s = src1s_vals[i]; |
| 1512 | for (j=0 ; j < sizeof(src2ul_vals)/sizeof(src2ul_vals[0]) ; j++) { |
| 1513 | unsigned long source2_ul = src2ul_vals[j]; |
| 1514 | |
| 1515 | short expected_result; |
| 1516 | short result; |
| 1517 | |
| 1518 | if (source2_ul <= 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip22;} |
| 1519 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 1520 | |
| 1521 | expected_result = (short) (source1_s % source2_ul); |
| 1522 | |
| 1523 | result = proc(source1_s, source2_ul); |
| 1524 | if (expected_result != result) { |
| 1525 | printf("Failed short %% unsigned long test, expected %d, got %d, for %d %% %lu\n", |
| 1526 | expected_result, result, source1_s, source2_ul); |
| 1527 | if (dumped == 0) cod_dump(gen_code); |
| 1528 | failed++; |
| 1529 | dumped++; |
| 1530 | } |
| 1531 | skip22: ; |
| 1532 | } |
| 1533 | } |
| 1534 | if (verbose) printf(" done\n"); |
| 1535 | cod_free_parse_context(context); |
| 1536 | cod_code_free(gen_code); |
| 1537 | } |
| 1538 | if ((only_run_test == NULL((void*)0)) || |
| 1539 | (strcmp(only_run_test, "s%l") == 0)) { |
| 1540 | int i, j; |
| 1541 | static char code[] = "{\n\ |
| 1542 | short a = p1;\n\ |
| 1543 | long b = p2;\n\ |
| 1544 | return a % b;\n\ |
| 1545 | }"; |
| 1546 | |
| 1547 | short (*proc)(short a, long b); |
| 1548 | cod_parse_context context = new_cod_parse_context(); |
| 1549 | int dumped = 0; |
| 1550 | |
| 1551 | cod_code gen_code; |
| 1552 | |
| 1553 | /* test for short % long */ |
| 1554 | if (verbose) printf("test for short %% long"); |
| 1555 | |
| 1556 | cod_assoc_externs(context, externs); |
| 1557 | cod_parse_for_context(extern_string, context); |
| 1558 | |
| 1559 | cod_subroutine_declaration("short proc(short p1, long p2)", |
| 1560 | context); |
| 1561 | gen_code = cod_code_gen(code, context); |
| 1562 | proc = (short (*)(short, long))(long)gen_code->func; |
| 1563 | |
| 1564 | |
| 1565 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 1566 | short source1_s = src1s_vals[i]; |
| 1567 | for (j=0 ; j < sizeof(src2l_vals)/sizeof(src2l_vals[0]) ; j++) { |
| 1568 | long source2_l = src2l_vals[j]; |
| 1569 | |
| 1570 | short expected_result; |
| 1571 | short result; |
| 1572 | |
| 1573 | if (source2_l <= 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip23;} |
| 1574 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 1575 | |
| 1576 | expected_result = (short) (source1_s % source2_l); |
| 1577 | |
| 1578 | result = proc(source1_s, source2_l); |
| 1579 | if (expected_result != result) { |
| 1580 | printf("Failed short %% long test, expected %d, got %d, for %d %% %ld\n", |
| 1581 | expected_result, result, source1_s, source2_l); |
| 1582 | if (dumped == 0) cod_dump(gen_code); |
| 1583 | failed++; |
| 1584 | dumped++; |
| 1585 | } |
| 1586 | skip23: ; |
| 1587 | } |
| 1588 | } |
| 1589 | if (verbose) printf(" done\n"); |
| 1590 | cod_free_parse_context(context); |
| 1591 | cod_code_free(gen_code); |
| 1592 | } |
| 1593 | } |
| 1594 | void mod_us_tests() |
| 1595 | { |
| 1596 | if ((only_run_test == NULL((void*)0)) || |
| 1597 | (strcmp(only_run_test, "us%c") == 0)) { |
| 1598 | int i, j; |
| 1599 | static char code[] = "{\n\ |
| 1600 | unsigned short a = p1;\n\ |
| 1601 | signed char b = p2;\n\ |
| 1602 | return a % b;\n\ |
| 1603 | }"; |
| 1604 | |
| 1605 | unsigned short (*proc)(unsigned short a, signed char b); |
| 1606 | cod_parse_context context = new_cod_parse_context(); |
| 1607 | int dumped = 0; |
| 1608 | |
| 1609 | cod_code gen_code; |
| 1610 | |
| 1611 | /* test for unsigned short % signed char */ |
| 1612 | if (verbose) printf("test for unsigned short %% signed char"); |
| 1613 | |
| 1614 | cod_assoc_externs(context, externs); |
| 1615 | cod_parse_for_context(extern_string, context); |
| 1616 | |
| 1617 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, signed char p2)", |
| 1618 | context); |
| 1619 | gen_code = cod_code_gen(code, context); |
| 1620 | proc = (unsigned short (*)(unsigned short, signed char))(long)gen_code->func; |
| 1621 | |
| 1622 | |
| 1623 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 1624 | unsigned short source1_us = src1us_vals[i]; |
| 1625 | for (j=0 ; j < sizeof(src2c_vals)/sizeof(src2c_vals[0]) ; j++) { |
| 1626 | signed char source2_c = src2c_vals[j]; |
| 1627 | |
| 1628 | unsigned short expected_result; |
| 1629 | unsigned short result; |
| 1630 | |
| 1631 | if (source2_c <= 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip24;} |
| 1632 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 1633 | |
| 1634 | expected_result = (unsigned short) (source1_us % source2_c); |
| 1635 | |
| 1636 | result = proc(source1_us, source2_c); |
| 1637 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 1638 | if (expected_result != result) { |
| 1639 | printf("Failed unsigned short %% signed char test, expected %u, got %u, for %u %% %d\n", |
| 1640 | expected_result, result, source1_us, source2_c); |
| 1641 | if (dumped == 0) cod_dump(gen_code); |
| 1642 | failed++; |
| 1643 | dumped++; |
| 1644 | } |
| 1645 | skip24: ; |
| 1646 | } |
| 1647 | } |
| 1648 | if (verbose) printf(" done\n"); |
| 1649 | cod_free_parse_context(context); |
| 1650 | cod_code_free(gen_code); |
| 1651 | } |
| 1652 | if ((only_run_test == NULL((void*)0)) || |
| 1653 | (strcmp(only_run_test, "us%uc") == 0)) { |
| 1654 | int i, j; |
| 1655 | static char code[] = "{\n\ |
| 1656 | unsigned short a = p1;\n\ |
| 1657 | unsigned char b = p2;\n\ |
| 1658 | return a % b;\n\ |
| 1659 | }"; |
| 1660 | |
| 1661 | unsigned short (*proc)(unsigned short a, unsigned char b); |
| 1662 | cod_parse_context context = new_cod_parse_context(); |
| 1663 | int dumped = 0; |
| 1664 | |
| 1665 | cod_code gen_code; |
| 1666 | |
| 1667 | /* test for unsigned short % unsigned char */ |
| 1668 | if (verbose) printf("test for unsigned short %% unsigned char"); |
| 1669 | |
| 1670 | cod_assoc_externs(context, externs); |
| 1671 | cod_parse_for_context(extern_string, context); |
| 1672 | |
| 1673 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, unsigned char p2)", |
| 1674 | context); |
| 1675 | gen_code = cod_code_gen(code, context); |
| 1676 | proc = (unsigned short (*)(unsigned short, unsigned char))(long)gen_code->func; |
| 1677 | |
| 1678 | |
| 1679 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 1680 | unsigned short source1_us = src1us_vals[i]; |
| 1681 | for (j=0 ; j < sizeof(src2uc_vals)/sizeof(src2uc_vals[0]) ; j++) { |
| 1682 | unsigned char source2_uc = src2uc_vals[j]; |
| 1683 | |
| 1684 | unsigned short expected_result; |
| 1685 | unsigned short result; |
| 1686 | |
| 1687 | if (source2_uc <= 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip25;} |
| 1688 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 1689 | |
| 1690 | expected_result = (unsigned short) (source1_us % source2_uc); |
| 1691 | |
| 1692 | result = proc(source1_us, source2_uc); |
| 1693 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 1694 | if (expected_result != result) { |
| 1695 | printf("Failed unsigned short %% unsigned char test, expected %u, got %u, for %u %% %u\n", |
| 1696 | expected_result, result, source1_us, source2_uc); |
| 1697 | if (dumped == 0) cod_dump(gen_code); |
| 1698 | failed++; |
| 1699 | dumped++; |
| 1700 | } |
| 1701 | skip25: ; |
| 1702 | } |
| 1703 | } |
| 1704 | if (verbose) printf(" done\n"); |
| 1705 | cod_free_parse_context(context); |
| 1706 | cod_code_free(gen_code); |
| 1707 | } |
| 1708 | if ((only_run_test == NULL((void*)0)) || |
| 1709 | (strcmp(only_run_test, "us%s") == 0)) { |
| 1710 | int i, j; |
| 1711 | static char code[] = "{\n\ |
| 1712 | unsigned short a = p1;\n\ |
| 1713 | short b = p2;\n\ |
| 1714 | return a % b;\n\ |
| 1715 | }"; |
| 1716 | |
| 1717 | unsigned short (*proc)(unsigned short a, short b); |
| 1718 | cod_parse_context context = new_cod_parse_context(); |
| 1719 | int dumped = 0; |
| 1720 | |
| 1721 | cod_code gen_code; |
| 1722 | |
| 1723 | /* test for unsigned short % short */ |
| 1724 | if (verbose) printf("test for unsigned short %% short"); |
| 1725 | |
| 1726 | cod_assoc_externs(context, externs); |
| 1727 | cod_parse_for_context(extern_string, context); |
| 1728 | |
| 1729 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, short p2)", |
| 1730 | context); |
| 1731 | gen_code = cod_code_gen(code, context); |
| 1732 | proc = (unsigned short (*)(unsigned short, short))(long)gen_code->func; |
| 1733 | |
| 1734 | |
| 1735 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 1736 | unsigned short source1_us = src1us_vals[i]; |
| 1737 | for (j=0 ; j < sizeof(src2s_vals)/sizeof(src2s_vals[0]) ; j++) { |
| 1738 | short source2_s = src2s_vals[j]; |
| 1739 | |
| 1740 | unsigned short expected_result; |
| 1741 | unsigned short result; |
| 1742 | |
| 1743 | if (source2_s <= 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip26;} |
| 1744 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 1745 | |
| 1746 | expected_result = (unsigned short) (source1_us % source2_s); |
| 1747 | |
| 1748 | result = proc(source1_us, source2_s); |
| 1749 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 1750 | if (expected_result != result) { |
| 1751 | printf("Failed unsigned short %% short test, expected %u, got %u, for %u %% %d\n", |
| 1752 | expected_result, result, source1_us, source2_s); |
| 1753 | if (dumped == 0) cod_dump(gen_code); |
| 1754 | failed++; |
| 1755 | dumped++; |
| 1756 | } |
| 1757 | skip26: ; |
| 1758 | } |
| 1759 | } |
| 1760 | if (verbose) printf(" done\n"); |
| 1761 | cod_free_parse_context(context); |
| 1762 | cod_code_free(gen_code); |
| 1763 | } |
| 1764 | if ((only_run_test == NULL((void*)0)) || |
| 1765 | (strcmp(only_run_test, "us%us") == 0)) { |
| 1766 | int i, j; |
| 1767 | static char code[] = "{\n\ |
| 1768 | unsigned short a = p1;\n\ |
| 1769 | unsigned short b = p2;\n\ |
| 1770 | return a % b;\n\ |
| 1771 | }"; |
| 1772 | |
| 1773 | unsigned short (*proc)(unsigned short a, unsigned short b); |
| 1774 | cod_parse_context context = new_cod_parse_context(); |
| 1775 | int dumped = 0; |
| 1776 | |
| 1777 | cod_code gen_code; |
| 1778 | |
| 1779 | /* test for unsigned short % unsigned short */ |
| 1780 | if (verbose) printf("test for unsigned short %% unsigned short"); |
| 1781 | |
| 1782 | cod_assoc_externs(context, externs); |
| 1783 | cod_parse_for_context(extern_string, context); |
| 1784 | |
| 1785 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, unsigned short p2)", |
| 1786 | context); |
| 1787 | gen_code = cod_code_gen(code, context); |
| 1788 | proc = (unsigned short (*)(unsigned short, unsigned short))(long)gen_code->func; |
| 1789 | |
| 1790 | |
| 1791 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 1792 | unsigned short source1_us = src1us_vals[i]; |
| 1793 | for (j=0 ; j < sizeof(src2us_vals)/sizeof(src2us_vals[0]) ; j++) { |
| 1794 | unsigned short source2_us = src2us_vals[j]; |
| 1795 | |
| 1796 | unsigned short expected_result; |
| 1797 | unsigned short result; |
| 1798 | |
| 1799 | if (source2_us <= 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip27;} |
| 1800 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 1801 | |
| 1802 | expected_result = (unsigned short) (source1_us % source2_us); |
| 1803 | |
| 1804 | result = proc(source1_us, source2_us); |
| 1805 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 1806 | if (expected_result != result) { |
| 1807 | printf("Failed unsigned short %% unsigned short test, expected %u, got %u, for %u %% %u\n", |
| 1808 | expected_result, result, source1_us, source2_us); |
| 1809 | if (dumped == 0) cod_dump(gen_code); |
| 1810 | failed++; |
| 1811 | dumped++; |
| 1812 | } |
| 1813 | skip27: ; |
| 1814 | } |
| 1815 | } |
| 1816 | if (verbose) printf(" done\n"); |
| 1817 | cod_free_parse_context(context); |
| 1818 | cod_code_free(gen_code); |
| 1819 | } |
| 1820 | if ((only_run_test == NULL((void*)0)) || |
| 1821 | (strcmp(only_run_test, "us%i") == 0)) { |
| 1822 | int i, j; |
| 1823 | static char code[] = "{\n\ |
| 1824 | unsigned short a = p1;\n\ |
| 1825 | int b = p2;\n\ |
| 1826 | return a % b;\n\ |
| 1827 | }"; |
| 1828 | |
| 1829 | unsigned short (*proc)(unsigned short a, int b); |
| 1830 | cod_parse_context context = new_cod_parse_context(); |
| 1831 | int dumped = 0; |
| 1832 | |
| 1833 | cod_code gen_code; |
| 1834 | |
| 1835 | /* test for unsigned short % int */ |
| 1836 | if (verbose) printf("test for unsigned short %% int"); |
| 1837 | |
| 1838 | cod_assoc_externs(context, externs); |
| 1839 | cod_parse_for_context(extern_string, context); |
| 1840 | |
| 1841 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, int p2)", |
| 1842 | context); |
| 1843 | gen_code = cod_code_gen(code, context); |
| 1844 | proc = (unsigned short (*)(unsigned short, int))(long)gen_code->func; |
| 1845 | |
| 1846 | |
| 1847 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 1848 | unsigned short source1_us = src1us_vals[i]; |
| 1849 | for (j=0 ; j < sizeof(src2i_vals)/sizeof(src2i_vals[0]) ; j++) { |
| 1850 | int source2_i = src2i_vals[j]; |
| 1851 | |
| 1852 | unsigned short expected_result; |
| 1853 | unsigned short result; |
| 1854 | |
| 1855 | if (source2_i <= 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip28;} |
| 1856 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 1857 | |
| 1858 | expected_result = (unsigned short) (source1_us % source2_i); |
| 1859 | |
| 1860 | result = proc(source1_us, source2_i); |
| 1861 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 1862 | if (expected_result != result) { |
| 1863 | printf("Failed unsigned short %% int test, expected %u, got %u, for %u %% %d\n", |
| 1864 | expected_result, result, source1_us, source2_i); |
| 1865 | if (dumped == 0) cod_dump(gen_code); |
| 1866 | failed++; |
| 1867 | dumped++; |
| 1868 | } |
| 1869 | skip28: ; |
| 1870 | } |
| 1871 | } |
| 1872 | if (verbose) printf(" done\n"); |
| 1873 | cod_free_parse_context(context); |
| 1874 | cod_code_free(gen_code); |
| 1875 | } |
| 1876 | if ((only_run_test == NULL((void*)0)) || |
| 1877 | (strcmp(only_run_test, "us%u") == 0)) { |
| 1878 | int i, j; |
| 1879 | static char code[] = "{\n\ |
| 1880 | unsigned short a = p1;\n\ |
| 1881 | unsigned int b = p2;\n\ |
| 1882 | return a % b;\n\ |
| 1883 | }"; |
| 1884 | |
| 1885 | unsigned short (*proc)(unsigned short a, unsigned int b); |
| 1886 | cod_parse_context context = new_cod_parse_context(); |
| 1887 | int dumped = 0; |
| 1888 | |
| 1889 | cod_code gen_code; |
| 1890 | |
| 1891 | /* test for unsigned short % unsigned int */ |
| 1892 | if (verbose) printf("test for unsigned short %% unsigned int"); |
| 1893 | |
| 1894 | cod_assoc_externs(context, externs); |
| 1895 | cod_parse_for_context(extern_string, context); |
| 1896 | |
| 1897 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, unsigned int p2)", |
| 1898 | context); |
| 1899 | gen_code = cod_code_gen(code, context); |
| 1900 | proc = (unsigned short (*)(unsigned short, unsigned int))(long)gen_code->func; |
| 1901 | |
| 1902 | |
| 1903 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 1904 | unsigned short source1_us = src1us_vals[i]; |
| 1905 | for (j=0 ; j < sizeof(src2u_vals)/sizeof(src2u_vals[0]) ; j++) { |
| 1906 | unsigned int source2_u = src2u_vals[j]; |
| 1907 | |
| 1908 | unsigned short expected_result; |
| 1909 | unsigned short result; |
| 1910 | |
| 1911 | if (source2_u <= 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip29;} |
| 1912 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 1913 | |
| 1914 | expected_result = (unsigned short) (source1_us % source2_u); |
| 1915 | |
| 1916 | result = proc(source1_us, source2_u); |
| 1917 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 1918 | if (expected_result != result) { |
| 1919 | printf("Failed unsigned short %% unsigned int test, expected %u, got %u, for %u %% %u\n", |
| 1920 | expected_result, result, source1_us, source2_u); |
| 1921 | if (dumped == 0) cod_dump(gen_code); |
| 1922 | failed++; |
| 1923 | dumped++; |
| 1924 | } |
| 1925 | skip29: ; |
| 1926 | } |
| 1927 | } |
| 1928 | if (verbose) printf(" done\n"); |
| 1929 | cod_free_parse_context(context); |
| 1930 | cod_code_free(gen_code); |
| 1931 | } |
| 1932 | if ((only_run_test == NULL((void*)0)) || |
| 1933 | (strcmp(only_run_test, "us%ul") == 0)) { |
| 1934 | int i, j; |
| 1935 | static char code[] = "{\n\ |
| 1936 | unsigned short a = p1;\n\ |
| 1937 | unsigned long b = p2;\n\ |
| 1938 | return a % b;\n\ |
| 1939 | }"; |
| 1940 | |
| 1941 | unsigned short (*proc)(unsigned short a, unsigned long b); |
| 1942 | cod_parse_context context = new_cod_parse_context(); |
| 1943 | int dumped = 0; |
| 1944 | |
| 1945 | cod_code gen_code; |
| 1946 | |
| 1947 | /* test for unsigned short % unsigned long */ |
| 1948 | if (verbose) printf("test for unsigned short %% unsigned long"); |
| 1949 | |
| 1950 | cod_assoc_externs(context, externs); |
| 1951 | cod_parse_for_context(extern_string, context); |
| 1952 | |
| 1953 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, unsigned long p2)", |
| 1954 | context); |
| 1955 | gen_code = cod_code_gen(code, context); |
| 1956 | proc = (unsigned short (*)(unsigned short, unsigned long))(long)gen_code->func; |
| 1957 | |
| 1958 | |
| 1959 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 1960 | unsigned short source1_us = src1us_vals[i]; |
| 1961 | for (j=0 ; j < sizeof(src2ul_vals)/sizeof(src2ul_vals[0]) ; j++) { |
| 1962 | unsigned long source2_ul = src2ul_vals[j]; |
| 1963 | |
| 1964 | unsigned short expected_result; |
| 1965 | unsigned short result; |
| 1966 | |
| 1967 | if (source2_ul <= 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip30;} |
| 1968 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 1969 | |
| 1970 | expected_result = (unsigned short) (source1_us % source2_ul); |
| 1971 | |
| 1972 | result = proc(source1_us, source2_ul); |
| 1973 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 1974 | if (expected_result != result) { |
| 1975 | printf("Failed unsigned short %% unsigned long test, expected %u, got %u, for %u %% %lu\n", |
| 1976 | expected_result, result, source1_us, source2_ul); |
| 1977 | if (dumped == 0) cod_dump(gen_code); |
| 1978 | failed++; |
| 1979 | dumped++; |
| 1980 | } |
| 1981 | skip30: ; |
| 1982 | } |
| 1983 | } |
| 1984 | if (verbose) printf(" done\n"); |
| 1985 | cod_free_parse_context(context); |
| 1986 | cod_code_free(gen_code); |
| 1987 | } |
| 1988 | if ((only_run_test == NULL((void*)0)) || |
| 1989 | (strcmp(only_run_test, "us%l") == 0)) { |
| 1990 | int i, j; |
| 1991 | static char code[] = "{\n\ |
| 1992 | unsigned short a = p1;\n\ |
| 1993 | long b = p2;\n\ |
| 1994 | return a % b;\n\ |
| 1995 | }"; |
| 1996 | |
| 1997 | unsigned short (*proc)(unsigned short a, long b); |
| 1998 | cod_parse_context context = new_cod_parse_context(); |
| 1999 | int dumped = 0; |
| 2000 | |
| 2001 | cod_code gen_code; |
| 2002 | |
| 2003 | /* test for unsigned short % long */ |
| 2004 | if (verbose) printf("test for unsigned short %% long"); |
| 2005 | |
| 2006 | cod_assoc_externs(context, externs); |
| 2007 | cod_parse_for_context(extern_string, context); |
| 2008 | |
| 2009 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, long p2)", |
| 2010 | context); |
| 2011 | gen_code = cod_code_gen(code, context); |
| 2012 | proc = (unsigned short (*)(unsigned short, long))(long)gen_code->func; |
| 2013 | |
| 2014 | |
| 2015 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 2016 | unsigned short source1_us = src1us_vals[i]; |
| 2017 | for (j=0 ; j < sizeof(src2l_vals)/sizeof(src2l_vals[0]) ; j++) { |
| 2018 | long source2_l = src2l_vals[j]; |
| 2019 | |
| 2020 | unsigned short expected_result; |
| 2021 | unsigned short result; |
| 2022 | |
| 2023 | if (source2_l <= 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip31;} |
| 2024 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 2025 | |
| 2026 | expected_result = (unsigned short) (source1_us % source2_l); |
| 2027 | |
| 2028 | result = proc(source1_us, source2_l); |
| 2029 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 2030 | if (expected_result != result) { |
| 2031 | printf("Failed unsigned short %% long test, expected %u, got %u, for %u %% %ld\n", |
| 2032 | expected_result, result, source1_us, source2_l); |
| 2033 | if (dumped == 0) cod_dump(gen_code); |
| 2034 | failed++; |
| 2035 | dumped++; |
| 2036 | } |
| 2037 | skip31: ; |
| 2038 | } |
| 2039 | } |
| 2040 | if (verbose) printf(" done\n"); |
| 2041 | cod_free_parse_context(context); |
| 2042 | cod_code_free(gen_code); |
| 2043 | } |
| 2044 | } |
| 2045 | void mod_i_tests() |
| 2046 | { |
| 2047 | if ((only_run_test == NULL((void*)0)) || |
| 2048 | (strcmp(only_run_test, "i%c") == 0)) { |
| 2049 | int i, j; |
| 2050 | static char code[] = "{\n\ |
| 2051 | int a = p1;\n\ |
| 2052 | signed char b = p2;\n\ |
| 2053 | return a % b;\n\ |
| 2054 | }"; |
| 2055 | |
| 2056 | int (*proc)(int a, signed char b); |
| 2057 | cod_parse_context context = new_cod_parse_context(); |
| 2058 | int dumped = 0; |
| 2059 | |
| 2060 | cod_code gen_code; |
| 2061 | |
| 2062 | /* test for int % signed char */ |
| 2063 | if (verbose) printf("test for int %% signed char"); |
| 2064 | |
| 2065 | cod_assoc_externs(context, externs); |
| 2066 | cod_parse_for_context(extern_string, context); |
| 2067 | |
| 2068 | cod_subroutine_declaration("int proc(int p1, signed char p2)", |
| 2069 | context); |
| 2070 | gen_code = cod_code_gen(code, context); |
| 2071 | proc = (int (*)(int, signed char))(long)gen_code->func; |
| 2072 | |
| 2073 | |
| 2074 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 2075 | int source1_i = src1i_vals[i]; |
| 2076 | for (j=0 ; j < sizeof(src2c_vals)/sizeof(src2c_vals[0]) ; j++) { |
| 2077 | signed char source2_c = src2c_vals[j]; |
| 2078 | |
| 2079 | int expected_result; |
| 2080 | int result; |
| 2081 | |
| 2082 | if (source2_c <= 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip32;} |
| 2083 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 2084 | |
| 2085 | expected_result = (int) (source1_i % source2_c); |
| 2086 | |
| 2087 | result = proc(source1_i, source2_c); |
| 2088 | if (expected_result != result) { |
| 2089 | printf("Failed int %% signed char test, expected %d, got %d, for %d %% %d\n", |
| 2090 | expected_result, result, source1_i, source2_c); |
| 2091 | if (dumped == 0) cod_dump(gen_code); |
| 2092 | failed++; |
| 2093 | dumped++; |
| 2094 | } |
| 2095 | skip32: ; |
| 2096 | } |
| 2097 | } |
| 2098 | if (verbose) printf(" done\n"); |
| 2099 | cod_free_parse_context(context); |
| 2100 | cod_code_free(gen_code); |
| 2101 | } |
| 2102 | if ((only_run_test == NULL((void*)0)) || |
| 2103 | (strcmp(only_run_test, "i%uc") == 0)) { |
| 2104 | int i, j; |
| 2105 | static char code[] = "{\n\ |
| 2106 | int a = p1;\n\ |
| 2107 | unsigned char b = p2;\n\ |
| 2108 | return a % b;\n\ |
| 2109 | }"; |
| 2110 | |
| 2111 | int (*proc)(int a, unsigned char b); |
| 2112 | cod_parse_context context = new_cod_parse_context(); |
| 2113 | int dumped = 0; |
| 2114 | |
| 2115 | cod_code gen_code; |
| 2116 | |
| 2117 | /* test for int % unsigned char */ |
| 2118 | if (verbose) printf("test for int %% unsigned char"); |
| 2119 | |
| 2120 | cod_assoc_externs(context, externs); |
| 2121 | cod_parse_for_context(extern_string, context); |
| 2122 | |
| 2123 | cod_subroutine_declaration("int proc(int p1, unsigned char p2)", |
| 2124 | context); |
| 2125 | gen_code = cod_code_gen(code, context); |
| 2126 | proc = (int (*)(int, unsigned char))(long)gen_code->func; |
| 2127 | |
| 2128 | |
| 2129 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 2130 | int source1_i = src1i_vals[i]; |
| 2131 | for (j=0 ; j < sizeof(src2uc_vals)/sizeof(src2uc_vals[0]) ; j++) { |
| 2132 | unsigned char source2_uc = src2uc_vals[j]; |
| 2133 | |
| 2134 | int expected_result; |
| 2135 | int result; |
| 2136 | |
| 2137 | if (source2_uc <= 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip33;} |
| 2138 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 2139 | |
| 2140 | expected_result = (int) (source1_i % source2_uc); |
| 2141 | |
| 2142 | result = proc(source1_i, source2_uc); |
| 2143 | if (expected_result != result) { |
| 2144 | printf("Failed int %% unsigned char test, expected %d, got %d, for %d %% %u\n", |
| 2145 | expected_result, result, source1_i, source2_uc); |
| 2146 | if (dumped == 0) cod_dump(gen_code); |
| 2147 | failed++; |
| 2148 | dumped++; |
| 2149 | } |
| 2150 | skip33: ; |
| 2151 | } |
| 2152 | } |
| 2153 | if (verbose) printf(" done\n"); |
| 2154 | cod_free_parse_context(context); |
| 2155 | cod_code_free(gen_code); |
| 2156 | } |
| 2157 | if ((only_run_test == NULL((void*)0)) || |
| 2158 | (strcmp(only_run_test, "i%s") == 0)) { |
| 2159 | int i, j; |
| 2160 | static char code[] = "{\n\ |
| 2161 | int a = p1;\n\ |
| 2162 | short b = p2;\n\ |
| 2163 | return a % b;\n\ |
| 2164 | }"; |
| 2165 | |
| 2166 | int (*proc)(int a, short b); |
| 2167 | cod_parse_context context = new_cod_parse_context(); |
| 2168 | int dumped = 0; |
| 2169 | |
| 2170 | cod_code gen_code; |
| 2171 | |
| 2172 | /* test for int % short */ |
| 2173 | if (verbose) printf("test for int %% short"); |
| 2174 | |
| 2175 | cod_assoc_externs(context, externs); |
| 2176 | cod_parse_for_context(extern_string, context); |
| 2177 | |
| 2178 | cod_subroutine_declaration("int proc(int p1, short p2)", |
| 2179 | context); |
| 2180 | gen_code = cod_code_gen(code, context); |
| 2181 | proc = (int (*)(int, short))(long)gen_code->func; |
| 2182 | |
| 2183 | |
| 2184 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 2185 | int source1_i = src1i_vals[i]; |
| 2186 | for (j=0 ; j < sizeof(src2s_vals)/sizeof(src2s_vals[0]) ; j++) { |
| 2187 | short source2_s = src2s_vals[j]; |
| 2188 | |
| 2189 | int expected_result; |
| 2190 | int result; |
| 2191 | |
| 2192 | if (source2_s <= 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip34;} |
| 2193 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 2194 | |
| 2195 | expected_result = (int) (source1_i % source2_s); |
| 2196 | |
| 2197 | result = proc(source1_i, source2_s); |
| 2198 | if (expected_result != result) { |
| 2199 | printf("Failed int %% short test, expected %d, got %d, for %d %% %d\n", |
| 2200 | expected_result, result, source1_i, source2_s); |
| 2201 | if (dumped == 0) cod_dump(gen_code); |
| 2202 | failed++; |
| 2203 | dumped++; |
| 2204 | } |
| 2205 | skip34: ; |
| 2206 | } |
| 2207 | } |
| 2208 | if (verbose) printf(" done\n"); |
| 2209 | cod_free_parse_context(context); |
| 2210 | cod_code_free(gen_code); |
| 2211 | } |
| 2212 | if ((only_run_test == NULL((void*)0)) || |
| 2213 | (strcmp(only_run_test, "i%us") == 0)) { |
| 2214 | int i, j; |
| 2215 | static char code[] = "{\n\ |
| 2216 | int a = p1;\n\ |
| 2217 | unsigned short b = p2;\n\ |
| 2218 | return a % b;\n\ |
| 2219 | }"; |
| 2220 | |
| 2221 | int (*proc)(int a, unsigned short b); |
| 2222 | cod_parse_context context = new_cod_parse_context(); |
| 2223 | int dumped = 0; |
| 2224 | |
| 2225 | cod_code gen_code; |
| 2226 | |
| 2227 | /* test for int % unsigned short */ |
| 2228 | if (verbose) printf("test for int %% unsigned short"); |
| 2229 | |
| 2230 | cod_assoc_externs(context, externs); |
| 2231 | cod_parse_for_context(extern_string, context); |
| 2232 | |
| 2233 | cod_subroutine_declaration("int proc(int p1, unsigned short p2)", |
| 2234 | context); |
| 2235 | gen_code = cod_code_gen(code, context); |
| 2236 | proc = (int (*)(int, unsigned short))(long)gen_code->func; |
| 2237 | |
| 2238 | |
| 2239 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 2240 | int source1_i = src1i_vals[i]; |
| 2241 | for (j=0 ; j < sizeof(src2us_vals)/sizeof(src2us_vals[0]) ; j++) { |
| 2242 | unsigned short source2_us = src2us_vals[j]; |
| 2243 | |
| 2244 | int expected_result; |
| 2245 | int result; |
| 2246 | |
| 2247 | if (source2_us <= 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip35;} |
| 2248 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 2249 | |
| 2250 | expected_result = (int) (source1_i % source2_us); |
| 2251 | |
| 2252 | result = proc(source1_i, source2_us); |
| 2253 | if (expected_result != result) { |
| 2254 | printf("Failed int %% unsigned short test, expected %d, got %d, for %d %% %u\n", |
| 2255 | expected_result, result, source1_i, source2_us); |
| 2256 | if (dumped == 0) cod_dump(gen_code); |
| 2257 | failed++; |
| 2258 | dumped++; |
| 2259 | } |
| 2260 | skip35: ; |
| 2261 | } |
| 2262 | } |
| 2263 | if (verbose) printf(" done\n"); |
| 2264 | cod_free_parse_context(context); |
| 2265 | cod_code_free(gen_code); |
| 2266 | } |
| 2267 | if ((only_run_test == NULL((void*)0)) || |
| 2268 | (strcmp(only_run_test, "i%i") == 0)) { |
| 2269 | int i, j; |
| 2270 | static char code[] = "{\n\ |
| 2271 | int a = p1;\n\ |
| 2272 | int b = p2;\n\ |
| 2273 | return a % b;\n\ |
| 2274 | }"; |
| 2275 | |
| 2276 | int (*proc)(int a, int b); |
| 2277 | cod_parse_context context = new_cod_parse_context(); |
| 2278 | int dumped = 0; |
| 2279 | |
| 2280 | cod_code gen_code; |
| 2281 | |
| 2282 | /* test for int % int */ |
| 2283 | if (verbose) printf("test for int %% int"); |
| 2284 | |
| 2285 | cod_assoc_externs(context, externs); |
| 2286 | cod_parse_for_context(extern_string, context); |
| 2287 | |
| 2288 | cod_subroutine_declaration("int proc(int p1, int p2)", |
| 2289 | context); |
| 2290 | gen_code = cod_code_gen(code, context); |
| 2291 | proc = (int (*)(int, int))(long)gen_code->func; |
| 2292 | |
| 2293 | |
| 2294 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 2295 | int source1_i = src1i_vals[i]; |
| 2296 | for (j=0 ; j < sizeof(src2i_vals)/sizeof(src2i_vals[0]) ; j++) { |
| 2297 | int source2_i = src2i_vals[j]; |
| 2298 | |
| 2299 | int expected_result; |
| 2300 | int result; |
| 2301 | |
| 2302 | if (source2_i <= 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip36;} |
| 2303 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 2304 | |
| 2305 | expected_result = (int) (source1_i % source2_i); |
| 2306 | |
| 2307 | result = proc(source1_i, source2_i); |
| 2308 | if (expected_result != result) { |
| 2309 | printf("Failed int %% int test, expected %d, got %d, for %d %% %d\n", |
| 2310 | expected_result, result, source1_i, source2_i); |
| 2311 | if (dumped == 0) cod_dump(gen_code); |
| 2312 | failed++; |
| 2313 | dumped++; |
| 2314 | } |
| 2315 | skip36: ; |
| 2316 | } |
| 2317 | } |
| 2318 | if (verbose) printf(" done\n"); |
| 2319 | cod_free_parse_context(context); |
| 2320 | cod_code_free(gen_code); |
| 2321 | } |
| 2322 | if ((only_run_test == NULL((void*)0)) || |
| 2323 | (strcmp(only_run_test, "i%u") == 0)) { |
| 2324 | int i, j; |
| 2325 | static char code[] = "{\n\ |
| 2326 | int a = p1;\n\ |
| 2327 | unsigned int b = p2;\n\ |
| 2328 | return a % b;\n\ |
| 2329 | }"; |
| 2330 | |
| 2331 | int (*proc)(int a, unsigned int b); |
| 2332 | cod_parse_context context = new_cod_parse_context(); |
| 2333 | int dumped = 0; |
| 2334 | |
| 2335 | cod_code gen_code; |
| 2336 | |
| 2337 | /* test for int % unsigned int */ |
| 2338 | if (verbose) printf("test for int %% unsigned int"); |
| 2339 | |
| 2340 | cod_assoc_externs(context, externs); |
| 2341 | cod_parse_for_context(extern_string, context); |
| 2342 | |
| 2343 | cod_subroutine_declaration("int proc(int p1, unsigned int p2)", |
| 2344 | context); |
| 2345 | gen_code = cod_code_gen(code, context); |
| 2346 | proc = (int (*)(int, unsigned int))(long)gen_code->func; |
| 2347 | |
| 2348 | |
| 2349 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 2350 | int source1_i = src1i_vals[i]; |
| 2351 | for (j=0 ; j < sizeof(src2u_vals)/sizeof(src2u_vals[0]) ; j++) { |
| 2352 | unsigned int source2_u = src2u_vals[j]; |
| 2353 | |
| 2354 | int expected_result; |
| 2355 | int result; |
| 2356 | |
| 2357 | if (source2_u <= 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip37;} |
| 2358 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 2359 | |
| 2360 | expected_result = (int) (source1_i % source2_u); |
| 2361 | |
| 2362 | result = proc(source1_i, source2_u); |
| 2363 | if (expected_result != result) { |
| 2364 | printf("Failed int %% unsigned int test, expected %d, got %d, for %d %% %u\n", |
| 2365 | expected_result, result, source1_i, source2_u); |
| 2366 | if (dumped == 0) cod_dump(gen_code); |
| 2367 | failed++; |
| 2368 | dumped++; |
| 2369 | } |
| 2370 | skip37: ; |
| 2371 | } |
| 2372 | } |
| 2373 | if (verbose) printf(" done\n"); |
| 2374 | cod_free_parse_context(context); |
| 2375 | cod_code_free(gen_code); |
| 2376 | } |
| 2377 | if ((only_run_test == NULL((void*)0)) || |
| 2378 | (strcmp(only_run_test, "i%ul") == 0)) { |
| 2379 | int i, j; |
| 2380 | static char code[] = "{\n\ |
| 2381 | int a = p1;\n\ |
| 2382 | unsigned long b = p2;\n\ |
| 2383 | return a % b;\n\ |
| 2384 | }"; |
| 2385 | |
| 2386 | int (*proc)(int a, unsigned long b); |
| 2387 | cod_parse_context context = new_cod_parse_context(); |
| 2388 | int dumped = 0; |
| 2389 | |
| 2390 | cod_code gen_code; |
| 2391 | |
| 2392 | /* test for int % unsigned long */ |
| 2393 | if (verbose) printf("test for int %% unsigned long"); |
| 2394 | |
| 2395 | cod_assoc_externs(context, externs); |
| 2396 | cod_parse_for_context(extern_string, context); |
| 2397 | |
| 2398 | cod_subroutine_declaration("int proc(int p1, unsigned long p2)", |
| 2399 | context); |
| 2400 | gen_code = cod_code_gen(code, context); |
| 2401 | proc = (int (*)(int, unsigned long))(long)gen_code->func; |
| 2402 | |
| 2403 | |
| 2404 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 2405 | int source1_i = src1i_vals[i]; |
| 2406 | for (j=0 ; j < sizeof(src2ul_vals)/sizeof(src2ul_vals[0]) ; j++) { |
| 2407 | unsigned long source2_ul = src2ul_vals[j]; |
| 2408 | |
| 2409 | int expected_result; |
| 2410 | int result; |
| 2411 | |
| 2412 | if (source2_ul <= 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip38;} |
| 2413 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 2414 | |
| 2415 | expected_result = (int) (source1_i % source2_ul); |
| 2416 | |
| 2417 | result = proc(source1_i, source2_ul); |
| 2418 | if (expected_result != result) { |
| 2419 | printf("Failed int %% unsigned long test, expected %d, got %d, for %d %% %lu\n", |
| 2420 | expected_result, result, source1_i, source2_ul); |
| 2421 | if (dumped == 0) cod_dump(gen_code); |
| 2422 | failed++; |
| 2423 | dumped++; |
| 2424 | } |
| 2425 | skip38: ; |
| 2426 | } |
| 2427 | } |
| 2428 | if (verbose) printf(" done\n"); |
| 2429 | cod_free_parse_context(context); |
| 2430 | cod_code_free(gen_code); |
| 2431 | } |
| 2432 | if ((only_run_test == NULL((void*)0)) || |
| 2433 | (strcmp(only_run_test, "i%l") == 0)) { |
| 2434 | int i, j; |
| 2435 | static char code[] = "{\n\ |
| 2436 | int a = p1;\n\ |
| 2437 | long b = p2;\n\ |
| 2438 | return a % b;\n\ |
| 2439 | }"; |
| 2440 | |
| 2441 | int (*proc)(int a, long b); |
| 2442 | cod_parse_context context = new_cod_parse_context(); |
| 2443 | int dumped = 0; |
| 2444 | |
| 2445 | cod_code gen_code; |
| 2446 | |
| 2447 | /* test for int % long */ |
| 2448 | if (verbose) printf("test for int %% long"); |
| 2449 | |
| 2450 | cod_assoc_externs(context, externs); |
| 2451 | cod_parse_for_context(extern_string, context); |
| 2452 | |
| 2453 | cod_subroutine_declaration("int proc(int p1, long p2)", |
| 2454 | context); |
| 2455 | gen_code = cod_code_gen(code, context); |
| 2456 | proc = (int (*)(int, long))(long)gen_code->func; |
| 2457 | |
| 2458 | |
| 2459 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 2460 | int source1_i = src1i_vals[i]; |
| 2461 | for (j=0 ; j < sizeof(src2l_vals)/sizeof(src2l_vals[0]) ; j++) { |
| 2462 | long source2_l = src2l_vals[j]; |
| 2463 | |
| 2464 | int expected_result; |
| 2465 | int result; |
| 2466 | |
| 2467 | if (source2_l <= 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip39;} |
| 2468 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 2469 | |
| 2470 | expected_result = (int) (source1_i % source2_l); |
| 2471 | |
| 2472 | result = proc(source1_i, source2_l); |
| 2473 | if (expected_result != result) { |
| 2474 | printf("Failed int %% long test, expected %d, got %d, for %d %% %ld\n", |
| 2475 | expected_result, result, source1_i, source2_l); |
| 2476 | if (dumped == 0) cod_dump(gen_code); |
| 2477 | failed++; |
| 2478 | dumped++; |
| 2479 | } |
| 2480 | skip39: ; |
| 2481 | } |
| 2482 | } |
| 2483 | if (verbose) printf(" done\n"); |
| 2484 | cod_free_parse_context(context); |
| 2485 | cod_code_free(gen_code); |
| 2486 | } |
| 2487 | } |
| 2488 | void mod_u_tests() |
| 2489 | { |
| 2490 | if ((only_run_test == NULL((void*)0)) || |
| 2491 | (strcmp(only_run_test, "u%c") == 0)) { |
| 2492 | int i, j; |
| 2493 | static char code[] = "{\n\ |
| 2494 | unsigned int a = p1;\n\ |
| 2495 | signed char b = p2;\n\ |
| 2496 | return a % b;\n\ |
| 2497 | }"; |
| 2498 | |
| 2499 | unsigned int (*proc)(unsigned int a, signed char b); |
| 2500 | cod_parse_context context = new_cod_parse_context(); |
| 2501 | int dumped = 0; |
| 2502 | |
| 2503 | cod_code gen_code; |
| 2504 | |
| 2505 | /* test for unsigned int % signed char */ |
| 2506 | if (verbose) printf("test for unsigned int %% signed char"); |
| 2507 | |
| 2508 | cod_assoc_externs(context, externs); |
| 2509 | cod_parse_for_context(extern_string, context); |
| 2510 | |
| 2511 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, signed char p2)", |
| 2512 | context); |
| 2513 | gen_code = cod_code_gen(code, context); |
| 2514 | proc = (unsigned int (*)(unsigned int, signed char))(long)gen_code->func; |
| 2515 | |
| 2516 | |
| 2517 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 2518 | unsigned int source1_u = src1u_vals[i]; |
| 2519 | for (j=0 ; j < sizeof(src2c_vals)/sizeof(src2c_vals[0]) ; j++) { |
| 2520 | signed char source2_c = src2c_vals[j]; |
| 2521 | |
| 2522 | unsigned int expected_result; |
| 2523 | unsigned int result; |
| 2524 | |
| 2525 | if (source2_c <= 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip40;} |
| 2526 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 2527 | |
| 2528 | expected_result = (unsigned int) (source1_u % source2_c); |
| 2529 | |
| 2530 | result = proc(source1_u, source2_c); |
| 2531 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 2532 | if (expected_result != result) { |
| 2533 | printf("Failed unsigned int %% signed char test, expected %u, got %u, for %u %% %d\n", |
| 2534 | expected_result, result, source1_u, source2_c); |
| 2535 | if (dumped == 0) cod_dump(gen_code); |
| 2536 | failed++; |
| 2537 | dumped++; |
| 2538 | } |
| 2539 | skip40: ; |
| 2540 | } |
| 2541 | } |
| 2542 | if (verbose) printf(" done\n"); |
| 2543 | cod_free_parse_context(context); |
| 2544 | cod_code_free(gen_code); |
| 2545 | } |
| 2546 | if ((only_run_test == NULL((void*)0)) || |
| 2547 | (strcmp(only_run_test, "u%uc") == 0)) { |
| 2548 | int i, j; |
| 2549 | static char code[] = "{\n\ |
| 2550 | unsigned int a = p1;\n\ |
| 2551 | unsigned char b = p2;\n\ |
| 2552 | return a % b;\n\ |
| 2553 | }"; |
| 2554 | |
| 2555 | unsigned int (*proc)(unsigned int a, unsigned char b); |
| 2556 | cod_parse_context context = new_cod_parse_context(); |
| 2557 | int dumped = 0; |
| 2558 | |
| 2559 | cod_code gen_code; |
| 2560 | |
| 2561 | /* test for unsigned int % unsigned char */ |
| 2562 | if (verbose) printf("test for unsigned int %% unsigned char"); |
| 2563 | |
| 2564 | cod_assoc_externs(context, externs); |
| 2565 | cod_parse_for_context(extern_string, context); |
| 2566 | |
| 2567 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, unsigned char p2)", |
| 2568 | context); |
| 2569 | gen_code = cod_code_gen(code, context); |
| 2570 | proc = (unsigned int (*)(unsigned int, unsigned char))(long)gen_code->func; |
| 2571 | |
| 2572 | |
| 2573 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 2574 | unsigned int source1_u = src1u_vals[i]; |
| 2575 | for (j=0 ; j < sizeof(src2uc_vals)/sizeof(src2uc_vals[0]) ; j++) { |
| 2576 | unsigned char source2_uc = src2uc_vals[j]; |
| 2577 | |
| 2578 | unsigned int expected_result; |
| 2579 | unsigned int result; |
| 2580 | |
| 2581 | if (source2_uc <= 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip41;} |
| 2582 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 2583 | |
| 2584 | expected_result = (unsigned int) (source1_u % source2_uc); |
| 2585 | |
| 2586 | result = proc(source1_u, source2_uc); |
| 2587 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 2588 | if (expected_result != result) { |
| 2589 | printf("Failed unsigned int %% unsigned char test, expected %u, got %u, for %u %% %u\n", |
| 2590 | expected_result, result, source1_u, source2_uc); |
| 2591 | if (dumped == 0) cod_dump(gen_code); |
| 2592 | failed++; |
| 2593 | dumped++; |
| 2594 | } |
| 2595 | skip41: ; |
| 2596 | } |
| 2597 | } |
| 2598 | if (verbose) printf(" done\n"); |
| 2599 | cod_free_parse_context(context); |
| 2600 | cod_code_free(gen_code); |
| 2601 | } |
| 2602 | if ((only_run_test == NULL((void*)0)) || |
| 2603 | (strcmp(only_run_test, "u%s") == 0)) { |
| 2604 | int i, j; |
| 2605 | static char code[] = "{\n\ |
| 2606 | unsigned int a = p1;\n\ |
| 2607 | short b = p2;\n\ |
| 2608 | return a % b;\n\ |
| 2609 | }"; |
| 2610 | |
| 2611 | unsigned int (*proc)(unsigned int a, short b); |
| 2612 | cod_parse_context context = new_cod_parse_context(); |
| 2613 | int dumped = 0; |
| 2614 | |
| 2615 | cod_code gen_code; |
| 2616 | |
| 2617 | /* test for unsigned int % short */ |
| 2618 | if (verbose) printf("test for unsigned int %% short"); |
| 2619 | |
| 2620 | cod_assoc_externs(context, externs); |
| 2621 | cod_parse_for_context(extern_string, context); |
| 2622 | |
| 2623 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, short p2)", |
| 2624 | context); |
| 2625 | gen_code = cod_code_gen(code, context); |
| 2626 | proc = (unsigned int (*)(unsigned int, short))(long)gen_code->func; |
| 2627 | |
| 2628 | |
| 2629 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 2630 | unsigned int source1_u = src1u_vals[i]; |
| 2631 | for (j=0 ; j < sizeof(src2s_vals)/sizeof(src2s_vals[0]) ; j++) { |
| 2632 | short source2_s = src2s_vals[j]; |
| 2633 | |
| 2634 | unsigned int expected_result; |
| 2635 | unsigned int result; |
| 2636 | |
| 2637 | if (source2_s <= 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip42;} |
| 2638 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 2639 | |
| 2640 | expected_result = (unsigned int) (source1_u % source2_s); |
| 2641 | |
| 2642 | result = proc(source1_u, source2_s); |
| 2643 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 2644 | if (expected_result != result) { |
| 2645 | printf("Failed unsigned int %% short test, expected %u, got %u, for %u %% %d\n", |
| 2646 | expected_result, result, source1_u, source2_s); |
| 2647 | if (dumped == 0) cod_dump(gen_code); |
| 2648 | failed++; |
| 2649 | dumped++; |
| 2650 | } |
| 2651 | skip42: ; |
| 2652 | } |
| 2653 | } |
| 2654 | if (verbose) printf(" done\n"); |
| 2655 | cod_free_parse_context(context); |
| 2656 | cod_code_free(gen_code); |
| 2657 | } |
| 2658 | if ((only_run_test == NULL((void*)0)) || |
| 2659 | (strcmp(only_run_test, "u%us") == 0)) { |
| 2660 | int i, j; |
| 2661 | static char code[] = "{\n\ |
| 2662 | unsigned int a = p1;\n\ |
| 2663 | unsigned short b = p2;\n\ |
| 2664 | return a % b;\n\ |
| 2665 | }"; |
| 2666 | |
| 2667 | unsigned int (*proc)(unsigned int a, unsigned short b); |
| 2668 | cod_parse_context context = new_cod_parse_context(); |
| 2669 | int dumped = 0; |
| 2670 | |
| 2671 | cod_code gen_code; |
| 2672 | |
| 2673 | /* test for unsigned int % unsigned short */ |
| 2674 | if (verbose) printf("test for unsigned int %% unsigned short"); |
| 2675 | |
| 2676 | cod_assoc_externs(context, externs); |
| 2677 | cod_parse_for_context(extern_string, context); |
| 2678 | |
| 2679 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, unsigned short p2)", |
| 2680 | context); |
| 2681 | gen_code = cod_code_gen(code, context); |
| 2682 | proc = (unsigned int (*)(unsigned int, unsigned short))(long)gen_code->func; |
| 2683 | |
| 2684 | |
| 2685 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 2686 | unsigned int source1_u = src1u_vals[i]; |
| 2687 | for (j=0 ; j < sizeof(src2us_vals)/sizeof(src2us_vals[0]) ; j++) { |
| 2688 | unsigned short source2_us = src2us_vals[j]; |
| 2689 | |
| 2690 | unsigned int expected_result; |
| 2691 | unsigned int result; |
| 2692 | |
| 2693 | if (source2_us <= 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip43;} |
| 2694 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 2695 | |
| 2696 | expected_result = (unsigned int) (source1_u % source2_us); |
| 2697 | |
| 2698 | result = proc(source1_u, source2_us); |
| 2699 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 2700 | if (expected_result != result) { |
| 2701 | printf("Failed unsigned int %% unsigned short test, expected %u, got %u, for %u %% %u\n", |
| 2702 | expected_result, result, source1_u, source2_us); |
| 2703 | if (dumped == 0) cod_dump(gen_code); |
| 2704 | failed++; |
| 2705 | dumped++; |
| 2706 | } |
| 2707 | skip43: ; |
| 2708 | } |
| 2709 | } |
| 2710 | if (verbose) printf(" done\n"); |
| 2711 | cod_free_parse_context(context); |
| 2712 | cod_code_free(gen_code); |
| 2713 | } |
| 2714 | if ((only_run_test == NULL((void*)0)) || |
| 2715 | (strcmp(only_run_test, "u%i") == 0)) { |
| 2716 | int i, j; |
| 2717 | static char code[] = "{\n\ |
| 2718 | unsigned int a = p1;\n\ |
| 2719 | int b = p2;\n\ |
| 2720 | return a % b;\n\ |
| 2721 | }"; |
| 2722 | |
| 2723 | unsigned int (*proc)(unsigned int a, int b); |
| 2724 | cod_parse_context context = new_cod_parse_context(); |
| 2725 | int dumped = 0; |
| 2726 | |
| 2727 | cod_code gen_code; |
| 2728 | |
| 2729 | /* test for unsigned int % int */ |
| 2730 | if (verbose) printf("test for unsigned int %% int"); |
| 2731 | |
| 2732 | cod_assoc_externs(context, externs); |
| 2733 | cod_parse_for_context(extern_string, context); |
| 2734 | |
| 2735 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, int p2)", |
| 2736 | context); |
| 2737 | gen_code = cod_code_gen(code, context); |
| 2738 | proc = (unsigned int (*)(unsigned int, int))(long)gen_code->func; |
| 2739 | |
| 2740 | |
| 2741 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 2742 | unsigned int source1_u = src1u_vals[i]; |
| 2743 | for (j=0 ; j < sizeof(src2i_vals)/sizeof(src2i_vals[0]) ; j++) { |
| 2744 | int source2_i = src2i_vals[j]; |
| 2745 | |
| 2746 | unsigned int expected_result; |
| 2747 | unsigned int result; |
| 2748 | |
| 2749 | if (source2_i <= 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip44;} |
| 2750 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 2751 | |
| 2752 | expected_result = (unsigned int) (source1_u % source2_i); |
| 2753 | |
| 2754 | result = proc(source1_u, source2_i); |
| 2755 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 2756 | if (expected_result != result) { |
| 2757 | printf("Failed unsigned int %% int test, expected %u, got %u, for %u %% %d\n", |
| 2758 | expected_result, result, source1_u, source2_i); |
| 2759 | if (dumped == 0) cod_dump(gen_code); |
| 2760 | failed++; |
| 2761 | dumped++; |
| 2762 | } |
| 2763 | skip44: ; |
| 2764 | } |
| 2765 | } |
| 2766 | if (verbose) printf(" done\n"); |
| 2767 | cod_free_parse_context(context); |
| 2768 | cod_code_free(gen_code); |
| 2769 | } |
| 2770 | if ((only_run_test == NULL((void*)0)) || |
| 2771 | (strcmp(only_run_test, "u%u") == 0)) { |
| 2772 | int i, j; |
| 2773 | static char code[] = "{\n\ |
| 2774 | unsigned int a = p1;\n\ |
| 2775 | unsigned int b = p2;\n\ |
| 2776 | return a % b;\n\ |
| 2777 | }"; |
| 2778 | |
| 2779 | unsigned int (*proc)(unsigned int a, unsigned int b); |
| 2780 | cod_parse_context context = new_cod_parse_context(); |
| 2781 | int dumped = 0; |
| 2782 | |
| 2783 | cod_code gen_code; |
| 2784 | |
| 2785 | /* test for unsigned int % unsigned int */ |
| 2786 | if (verbose) printf("test for unsigned int %% unsigned int"); |
| 2787 | |
| 2788 | cod_assoc_externs(context, externs); |
| 2789 | cod_parse_for_context(extern_string, context); |
| 2790 | |
| 2791 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, unsigned int p2)", |
| 2792 | context); |
| 2793 | gen_code = cod_code_gen(code, context); |
| 2794 | proc = (unsigned int (*)(unsigned int, unsigned int))(long)gen_code->func; |
| 2795 | |
| 2796 | |
| 2797 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 2798 | unsigned int source1_u = src1u_vals[i]; |
| 2799 | for (j=0 ; j < sizeof(src2u_vals)/sizeof(src2u_vals[0]) ; j++) { |
| 2800 | unsigned int source2_u = src2u_vals[j]; |
| 2801 | |
| 2802 | unsigned int expected_result; |
| 2803 | unsigned int result; |
| 2804 | |
| 2805 | if (source2_u <= 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip45;} |
| 2806 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 2807 | |
| 2808 | expected_result = (unsigned int) (source1_u % source2_u); |
| 2809 | |
| 2810 | result = proc(source1_u, source2_u); |
| 2811 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 2812 | if (expected_result != result) { |
| 2813 | printf("Failed unsigned int %% unsigned int test, expected %u, got %u, for %u %% %u\n", |
| 2814 | expected_result, result, source1_u, source2_u); |
| 2815 | if (dumped == 0) cod_dump(gen_code); |
| 2816 | failed++; |
| 2817 | dumped++; |
| 2818 | } |
| 2819 | skip45: ; |
| 2820 | } |
| 2821 | } |
| 2822 | if (verbose) printf(" done\n"); |
| 2823 | cod_free_parse_context(context); |
| 2824 | cod_code_free(gen_code); |
| 2825 | } |
| 2826 | if ((only_run_test == NULL((void*)0)) || |
| 2827 | (strcmp(only_run_test, "u%ul") == 0)) { |
| 2828 | int i, j; |
| 2829 | static char code[] = "{\n\ |
| 2830 | unsigned int a = p1;\n\ |
| 2831 | unsigned long b = p2;\n\ |
| 2832 | return a % b;\n\ |
| 2833 | }"; |
| 2834 | |
| 2835 | unsigned int (*proc)(unsigned int a, unsigned long b); |
| 2836 | cod_parse_context context = new_cod_parse_context(); |
| 2837 | int dumped = 0; |
| 2838 | |
| 2839 | cod_code gen_code; |
| 2840 | |
| 2841 | /* test for unsigned int % unsigned long */ |
| 2842 | if (verbose) printf("test for unsigned int %% unsigned long"); |
| 2843 | |
| 2844 | cod_assoc_externs(context, externs); |
| 2845 | cod_parse_for_context(extern_string, context); |
| 2846 | |
| 2847 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, unsigned long p2)", |
| 2848 | context); |
| 2849 | gen_code = cod_code_gen(code, context); |
| 2850 | proc = (unsigned int (*)(unsigned int, unsigned long))(long)gen_code->func; |
| 2851 | |
| 2852 | |
| 2853 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 2854 | unsigned int source1_u = src1u_vals[i]; |
| 2855 | for (j=0 ; j < sizeof(src2ul_vals)/sizeof(src2ul_vals[0]) ; j++) { |
| 2856 | unsigned long source2_ul = src2ul_vals[j]; |
| 2857 | |
| 2858 | unsigned int expected_result; |
| 2859 | unsigned int result; |
| 2860 | |
| 2861 | if (source2_ul <= 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip46;} |
| 2862 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 2863 | |
| 2864 | expected_result = (unsigned int) (source1_u % source2_ul); |
| 2865 | |
| 2866 | result = proc(source1_u, source2_ul); |
| 2867 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 2868 | if (expected_result != result) { |
| 2869 | printf("Failed unsigned int %% unsigned long test, expected %u, got %u, for %u %% %lu\n", |
| 2870 | expected_result, result, source1_u, source2_ul); |
| 2871 | if (dumped == 0) cod_dump(gen_code); |
| 2872 | failed++; |
| 2873 | dumped++; |
| 2874 | } |
| 2875 | skip46: ; |
| 2876 | } |
| 2877 | } |
| 2878 | if (verbose) printf(" done\n"); |
| 2879 | cod_free_parse_context(context); |
| 2880 | cod_code_free(gen_code); |
| 2881 | } |
| 2882 | if ((only_run_test == NULL((void*)0)) || |
| 2883 | (strcmp(only_run_test, "u%l") == 0)) { |
| 2884 | int i, j; |
| 2885 | static char code[] = "{\n\ |
| 2886 | unsigned int a = p1;\n\ |
| 2887 | long b = p2;\n\ |
| 2888 | return a % b;\n\ |
| 2889 | }"; |
| 2890 | |
| 2891 | unsigned int (*proc)(unsigned int a, long b); |
| 2892 | cod_parse_context context = new_cod_parse_context(); |
| 2893 | int dumped = 0; |
| 2894 | |
| 2895 | cod_code gen_code; |
| 2896 | |
| 2897 | /* test for unsigned int % long */ |
| 2898 | if (verbose) printf("test for unsigned int %% long"); |
| 2899 | |
| 2900 | cod_assoc_externs(context, externs); |
| 2901 | cod_parse_for_context(extern_string, context); |
| 2902 | |
| 2903 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, long p2)", |
| 2904 | context); |
| 2905 | gen_code = cod_code_gen(code, context); |
| 2906 | proc = (unsigned int (*)(unsigned int, long))(long)gen_code->func; |
| 2907 | |
| 2908 | |
| 2909 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 2910 | unsigned int source1_u = src1u_vals[i]; |
| 2911 | for (j=0 ; j < sizeof(src2l_vals)/sizeof(src2l_vals[0]) ; j++) { |
| 2912 | long source2_l = src2l_vals[j]; |
| 2913 | |
| 2914 | unsigned int expected_result; |
| 2915 | unsigned int result; |
| 2916 | |
| 2917 | if (source2_l <= 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip47;} |
| 2918 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 2919 | |
| 2920 | expected_result = (unsigned int) (source1_u % source2_l); |
| 2921 | |
| 2922 | result = proc(source1_u, source2_l); |
| 2923 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 2924 | if (expected_result != result) { |
| 2925 | printf("Failed unsigned int %% long test, expected %u, got %u, for %u %% %ld\n", |
| 2926 | expected_result, result, source1_u, source2_l); |
| 2927 | if (dumped == 0) cod_dump(gen_code); |
| 2928 | failed++; |
| 2929 | dumped++; |
| 2930 | } |
| 2931 | skip47: ; |
| 2932 | } |
| 2933 | } |
| 2934 | if (verbose) printf(" done\n"); |
| 2935 | cod_free_parse_context(context); |
| 2936 | cod_code_free(gen_code); |
| 2937 | } |
| 2938 | } |
| 2939 | void mod_ul_tests() |
| 2940 | { |
| 2941 | if ((only_run_test == NULL((void*)0)) || |
| 2942 | (strcmp(only_run_test, "ul%c") == 0)) { |
| 2943 | int i, j; |
| 2944 | static char code[] = "{\n\ |
| 2945 | unsigned long a = p1;\n\ |
| 2946 | signed char b = p2;\n\ |
| 2947 | return a % b;\n\ |
| 2948 | }"; |
| 2949 | |
| 2950 | unsigned long (*proc)(unsigned long a, signed char b); |
| 2951 | cod_parse_context context = new_cod_parse_context(); |
| 2952 | int dumped = 0; |
| 2953 | |
| 2954 | cod_code gen_code; |
| 2955 | |
| 2956 | /* test for unsigned long % signed char */ |
| 2957 | if (verbose) printf("test for unsigned long %% signed char"); |
| 2958 | |
| 2959 | cod_assoc_externs(context, externs); |
| 2960 | cod_parse_for_context(extern_string, context); |
| 2961 | |
| 2962 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, signed char p2)", |
| 2963 | context); |
| 2964 | gen_code = cod_code_gen(code, context); |
| 2965 | proc = (unsigned long (*)(unsigned long, signed char))(long)gen_code->func; |
| 2966 | |
| 2967 | |
| 2968 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 2969 | unsigned long source1_ul = src1ul_vals[i]; |
| 2970 | for (j=0 ; j < sizeof(src2c_vals)/sizeof(src2c_vals[0]) ; j++) { |
| 2971 | signed char source2_c = src2c_vals[j]; |
| 2972 | |
| 2973 | unsigned long expected_result; |
| 2974 | unsigned long result; |
| 2975 | |
| 2976 | if (source2_c <= 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip48;} |
| 2977 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 2978 | |
| 2979 | expected_result = (unsigned long) (source1_ul % source2_c); |
| 2980 | |
| 2981 | result = proc(source1_ul, source2_c); |
| 2982 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 2983 | if (expected_result != result) { |
| 2984 | printf("Failed unsigned long %% signed char test, expected %lu, got %lu, for %lu %% %d\n", |
| 2985 | expected_result, result, source1_ul, source2_c); |
| 2986 | if (dumped == 0) cod_dump(gen_code); |
| 2987 | failed++; |
| 2988 | dumped++; |
| 2989 | } |
| 2990 | skip48: ; |
| 2991 | } |
| 2992 | } |
| 2993 | if (verbose) printf(" done\n"); |
| 2994 | cod_free_parse_context(context); |
| 2995 | cod_code_free(gen_code); |
| 2996 | } |
| 2997 | if ((only_run_test == NULL((void*)0)) || |
| 2998 | (strcmp(only_run_test, "ul%uc") == 0)) { |
| 2999 | int i, j; |
| 3000 | static char code[] = "{\n\ |
| 3001 | unsigned long a = p1;\n\ |
| 3002 | unsigned char b = p2;\n\ |
| 3003 | return a % b;\n\ |
| 3004 | }"; |
| 3005 | |
| 3006 | unsigned long (*proc)(unsigned long a, unsigned char b); |
| 3007 | cod_parse_context context = new_cod_parse_context(); |
| 3008 | int dumped = 0; |
| 3009 | |
| 3010 | cod_code gen_code; |
| 3011 | |
| 3012 | /* test for unsigned long % unsigned char */ |
| 3013 | if (verbose) printf("test for unsigned long %% unsigned char"); |
| 3014 | |
| 3015 | cod_assoc_externs(context, externs); |
| 3016 | cod_parse_for_context(extern_string, context); |
| 3017 | |
| 3018 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, unsigned char p2)", |
| 3019 | context); |
| 3020 | gen_code = cod_code_gen(code, context); |
| 3021 | proc = (unsigned long (*)(unsigned long, unsigned char))(long)gen_code->func; |
| 3022 | |
| 3023 | |
| 3024 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 3025 | unsigned long source1_ul = src1ul_vals[i]; |
| 3026 | for (j=0 ; j < sizeof(src2uc_vals)/sizeof(src2uc_vals[0]) ; j++) { |
| 3027 | unsigned char source2_uc = src2uc_vals[j]; |
| 3028 | |
| 3029 | unsigned long expected_result; |
| 3030 | unsigned long result; |
| 3031 | |
| 3032 | if (source2_uc <= 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip49;} |
| 3033 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 3034 | |
| 3035 | expected_result = (unsigned long) (source1_ul % source2_uc); |
| 3036 | |
| 3037 | result = proc(source1_ul, source2_uc); |
| 3038 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 3039 | if (expected_result != result) { |
| 3040 | printf("Failed unsigned long %% unsigned char test, expected %lu, got %lu, for %lu %% %u\n", |
| 3041 | expected_result, result, source1_ul, source2_uc); |
| 3042 | if (dumped == 0) cod_dump(gen_code); |
| 3043 | failed++; |
| 3044 | dumped++; |
| 3045 | } |
| 3046 | skip49: ; |
| 3047 | } |
| 3048 | } |
| 3049 | if (verbose) printf(" done\n"); |
| 3050 | cod_free_parse_context(context); |
| 3051 | cod_code_free(gen_code); |
| 3052 | } |
| 3053 | if ((only_run_test == NULL((void*)0)) || |
| 3054 | (strcmp(only_run_test, "ul%s") == 0)) { |
| 3055 | int i, j; |
| 3056 | static char code[] = "{\n\ |
| 3057 | unsigned long a = p1;\n\ |
| 3058 | short b = p2;\n\ |
| 3059 | return a % b;\n\ |
| 3060 | }"; |
| 3061 | |
| 3062 | unsigned long (*proc)(unsigned long a, short b); |
| 3063 | cod_parse_context context = new_cod_parse_context(); |
| 3064 | int dumped = 0; |
| 3065 | |
| 3066 | cod_code gen_code; |
| 3067 | |
| 3068 | /* test for unsigned long % short */ |
| 3069 | if (verbose) printf("test for unsigned long %% short"); |
| 3070 | |
| 3071 | cod_assoc_externs(context, externs); |
| 3072 | cod_parse_for_context(extern_string, context); |
| 3073 | |
| 3074 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, short p2)", |
| 3075 | context); |
| 3076 | gen_code = cod_code_gen(code, context); |
| 3077 | proc = (unsigned long (*)(unsigned long, short))(long)gen_code->func; |
| 3078 | |
| 3079 | |
| 3080 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 3081 | unsigned long source1_ul = src1ul_vals[i]; |
| 3082 | for (j=0 ; j < sizeof(src2s_vals)/sizeof(src2s_vals[0]) ; j++) { |
| 3083 | short source2_s = src2s_vals[j]; |
| 3084 | |
| 3085 | unsigned long expected_result; |
| 3086 | unsigned long result; |
| 3087 | |
| 3088 | if (source2_s <= 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip50;} |
| 3089 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 3090 | |
| 3091 | expected_result = (unsigned long) (source1_ul % source2_s); |
| 3092 | |
| 3093 | result = proc(source1_ul, source2_s); |
| 3094 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 3095 | if (expected_result != result) { |
| 3096 | printf("Failed unsigned long %% short test, expected %lu, got %lu, for %lu %% %d\n", |
| 3097 | expected_result, result, source1_ul, source2_s); |
| 3098 | if (dumped == 0) cod_dump(gen_code); |
| 3099 | failed++; |
| 3100 | dumped++; |
| 3101 | } |
| 3102 | skip50: ; |
| 3103 | } |
| 3104 | } |
| 3105 | if (verbose) printf(" done\n"); |
| 3106 | cod_free_parse_context(context); |
| 3107 | cod_code_free(gen_code); |
| 3108 | } |
| 3109 | if ((only_run_test == NULL((void*)0)) || |
| 3110 | (strcmp(only_run_test, "ul%us") == 0)) { |
| 3111 | int i, j; |
| 3112 | static char code[] = "{\n\ |
| 3113 | unsigned long a = p1;\n\ |
| 3114 | unsigned short b = p2;\n\ |
| 3115 | return a % b;\n\ |
| 3116 | }"; |
| 3117 | |
| 3118 | unsigned long (*proc)(unsigned long a, unsigned short b); |
| 3119 | cod_parse_context context = new_cod_parse_context(); |
| 3120 | int dumped = 0; |
| 3121 | |
| 3122 | cod_code gen_code; |
| 3123 | |
| 3124 | /* test for unsigned long % unsigned short */ |
| 3125 | if (verbose) printf("test for unsigned long %% unsigned short"); |
| 3126 | |
| 3127 | cod_assoc_externs(context, externs); |
| 3128 | cod_parse_for_context(extern_string, context); |
| 3129 | |
| 3130 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, unsigned short p2)", |
| 3131 | context); |
| 3132 | gen_code = cod_code_gen(code, context); |
| 3133 | proc = (unsigned long (*)(unsigned long, unsigned short))(long)gen_code->func; |
| 3134 | |
| 3135 | |
| 3136 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 3137 | unsigned long source1_ul = src1ul_vals[i]; |
| 3138 | for (j=0 ; j < sizeof(src2us_vals)/sizeof(src2us_vals[0]) ; j++) { |
| 3139 | unsigned short source2_us = src2us_vals[j]; |
| 3140 | |
| 3141 | unsigned long expected_result; |
| 3142 | unsigned long result; |
| 3143 | |
| 3144 | if (source2_us <= 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip51;} |
| 3145 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 3146 | |
| 3147 | expected_result = (unsigned long) (source1_ul % source2_us); |
| 3148 | |
| 3149 | result = proc(source1_ul, source2_us); |
| 3150 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 3151 | if (expected_result != result) { |
| 3152 | printf("Failed unsigned long %% unsigned short test, expected %lu, got %lu, for %lu %% %u\n", |
| 3153 | expected_result, result, source1_ul, source2_us); |
| 3154 | if (dumped == 0) cod_dump(gen_code); |
| 3155 | failed++; |
| 3156 | dumped++; |
| 3157 | } |
| 3158 | skip51: ; |
| 3159 | } |
| 3160 | } |
| 3161 | if (verbose) printf(" done\n"); |
| 3162 | cod_free_parse_context(context); |
| 3163 | cod_code_free(gen_code); |
| 3164 | } |
| 3165 | if ((only_run_test == NULL((void*)0)) || |
| 3166 | (strcmp(only_run_test, "ul%i") == 0)) { |
| 3167 | int i, j; |
| 3168 | static char code[] = "{\n\ |
| 3169 | unsigned long a = p1;\n\ |
| 3170 | int b = p2;\n\ |
| 3171 | return a % b;\n\ |
| 3172 | }"; |
| 3173 | |
| 3174 | unsigned long (*proc)(unsigned long a, int b); |
| 3175 | cod_parse_context context = new_cod_parse_context(); |
| 3176 | int dumped = 0; |
| 3177 | |
| 3178 | cod_code gen_code; |
| 3179 | |
| 3180 | /* test for unsigned long % int */ |
| 3181 | if (verbose) printf("test for unsigned long %% int"); |
| 3182 | |
| 3183 | cod_assoc_externs(context, externs); |
| 3184 | cod_parse_for_context(extern_string, context); |
| 3185 | |
| 3186 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, int p2)", |
| 3187 | context); |
| 3188 | gen_code = cod_code_gen(code, context); |
| 3189 | proc = (unsigned long (*)(unsigned long, int))(long)gen_code->func; |
| 3190 | |
| 3191 | |
| 3192 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 3193 | unsigned long source1_ul = src1ul_vals[i]; |
| 3194 | for (j=0 ; j < sizeof(src2i_vals)/sizeof(src2i_vals[0]) ; j++) { |
| 3195 | int source2_i = src2i_vals[j]; |
| 3196 | |
| 3197 | unsigned long expected_result; |
| 3198 | unsigned long result; |
| 3199 | |
| 3200 | if (source2_i <= 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip52;} |
| 3201 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 3202 | |
| 3203 | expected_result = (unsigned long) (source1_ul % source2_i); |
| 3204 | |
| 3205 | result = proc(source1_ul, source2_i); |
| 3206 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 3207 | if (expected_result != result) { |
| 3208 | printf("Failed unsigned long %% int test, expected %lu, got %lu, for %lu %% %d\n", |
| 3209 | expected_result, result, source1_ul, source2_i); |
| 3210 | if (dumped == 0) cod_dump(gen_code); |
| 3211 | failed++; |
| 3212 | dumped++; |
| 3213 | } |
| 3214 | skip52: ; |
| 3215 | } |
| 3216 | } |
| 3217 | if (verbose) printf(" done\n"); |
| 3218 | cod_free_parse_context(context); |
| 3219 | cod_code_free(gen_code); |
| 3220 | } |
| 3221 | if ((only_run_test == NULL((void*)0)) || |
| 3222 | (strcmp(only_run_test, "ul%u") == 0)) { |
| 3223 | int i, j; |
| 3224 | static char code[] = "{\n\ |
| 3225 | unsigned long a = p1;\n\ |
| 3226 | unsigned int b = p2;\n\ |
| 3227 | return a % b;\n\ |
| 3228 | }"; |
| 3229 | |
| 3230 | unsigned long (*proc)(unsigned long a, unsigned int b); |
| 3231 | cod_parse_context context = new_cod_parse_context(); |
| 3232 | int dumped = 0; |
| 3233 | |
| 3234 | cod_code gen_code; |
| 3235 | |
| 3236 | /* test for unsigned long % unsigned int */ |
| 3237 | if (verbose) printf("test for unsigned long %% unsigned int"); |
| 3238 | |
| 3239 | cod_assoc_externs(context, externs); |
| 3240 | cod_parse_for_context(extern_string, context); |
| 3241 | |
| 3242 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, unsigned int p2)", |
| 3243 | context); |
| 3244 | gen_code = cod_code_gen(code, context); |
| 3245 | proc = (unsigned long (*)(unsigned long, unsigned int))(long)gen_code->func; |
| 3246 | |
| 3247 | |
| 3248 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 3249 | unsigned long source1_ul = src1ul_vals[i]; |
| 3250 | for (j=0 ; j < sizeof(src2u_vals)/sizeof(src2u_vals[0]) ; j++) { |
| 3251 | unsigned int source2_u = src2u_vals[j]; |
| 3252 | |
| 3253 | unsigned long expected_result; |
| 3254 | unsigned long result; |
| 3255 | |
| 3256 | if (source2_u <= 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip53;} |
| 3257 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 3258 | |
| 3259 | expected_result = (unsigned long) (source1_ul % source2_u); |
| 3260 | |
| 3261 | result = proc(source1_ul, source2_u); |
| 3262 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 3263 | if (expected_result != result) { |
| 3264 | printf("Failed unsigned long %% unsigned int test, expected %lu, got %lu, for %lu %% %u\n", |
| 3265 | expected_result, result, source1_ul, source2_u); |
| 3266 | if (dumped == 0) cod_dump(gen_code); |
| 3267 | failed++; |
| 3268 | dumped++; |
| 3269 | } |
| 3270 | skip53: ; |
| 3271 | } |
| 3272 | } |
| 3273 | if (verbose) printf(" done\n"); |
| 3274 | cod_free_parse_context(context); |
| 3275 | cod_code_free(gen_code); |
| 3276 | } |
| 3277 | if ((only_run_test == NULL((void*)0)) || |
| 3278 | (strcmp(only_run_test, "ul%ul") == 0)) { |
| 3279 | int i, j; |
| 3280 | static char code[] = "{\n\ |
| 3281 | unsigned long a = p1;\n\ |
| 3282 | unsigned long b = p2;\n\ |
| 3283 | return a % b;\n\ |
| 3284 | }"; |
| 3285 | |
| 3286 | unsigned long (*proc)(unsigned long a, unsigned long b); |
| 3287 | cod_parse_context context = new_cod_parse_context(); |
| 3288 | int dumped = 0; |
| 3289 | |
| 3290 | cod_code gen_code; |
| 3291 | |
| 3292 | /* test for unsigned long % unsigned long */ |
| 3293 | if (verbose) printf("test for unsigned long %% unsigned long"); |
| 3294 | |
| 3295 | cod_assoc_externs(context, externs); |
| 3296 | cod_parse_for_context(extern_string, context); |
| 3297 | |
| 3298 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, unsigned long p2)", |
| 3299 | context); |
| 3300 | gen_code = cod_code_gen(code, context); |
| 3301 | proc = (unsigned long (*)(unsigned long, unsigned long))(long)gen_code->func; |
| 3302 | |
| 3303 | |
| 3304 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 3305 | unsigned long source1_ul = src1ul_vals[i]; |
| 3306 | for (j=0 ; j < sizeof(src2ul_vals)/sizeof(src2ul_vals[0]) ; j++) { |
| 3307 | unsigned long source2_ul = src2ul_vals[j]; |
| 3308 | |
| 3309 | unsigned long expected_result; |
| 3310 | unsigned long result; |
| 3311 | |
| 3312 | if (source2_ul <= 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip54;} |
| 3313 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 3314 | |
| 3315 | expected_result = (unsigned long) (source1_ul % source2_ul); |
| 3316 | |
| 3317 | result = proc(source1_ul, source2_ul); |
| 3318 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 3319 | if (expected_result != result) { |
| 3320 | printf("Failed unsigned long %% unsigned long test, expected %lu, got %lu, for %lu %% %lu\n", |
| 3321 | expected_result, result, source1_ul, source2_ul); |
| 3322 | if (dumped == 0) cod_dump(gen_code); |
| 3323 | failed++; |
| 3324 | dumped++; |
| 3325 | } |
| 3326 | skip54: ; |
| 3327 | } |
| 3328 | } |
| 3329 | if (verbose) printf(" done\n"); |
| 3330 | cod_free_parse_context(context); |
| 3331 | cod_code_free(gen_code); |
| 3332 | } |
| 3333 | if ((only_run_test == NULL((void*)0)) || |
| 3334 | (strcmp(only_run_test, "ul%l") == 0)) { |
| 3335 | int i, j; |
| 3336 | static char code[] = "{\n\ |
| 3337 | unsigned long a = p1;\n\ |
| 3338 | long b = p2;\n\ |
| 3339 | return a % b;\n\ |
| 3340 | }"; |
| 3341 | |
| 3342 | unsigned long (*proc)(unsigned long a, long b); |
| 3343 | cod_parse_context context = new_cod_parse_context(); |
| 3344 | int dumped = 0; |
| 3345 | |
| 3346 | cod_code gen_code; |
| 3347 | |
| 3348 | /* test for unsigned long % long */ |
| 3349 | if (verbose) printf("test for unsigned long %% long"); |
| 3350 | |
| 3351 | cod_assoc_externs(context, externs); |
| 3352 | cod_parse_for_context(extern_string, context); |
| 3353 | |
| 3354 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, long p2)", |
| 3355 | context); |
| 3356 | gen_code = cod_code_gen(code, context); |
| 3357 | proc = (unsigned long (*)(unsigned long, long))(long)gen_code->func; |
| 3358 | |
| 3359 | |
| 3360 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 3361 | unsigned long source1_ul = src1ul_vals[i]; |
| 3362 | for (j=0 ; j < sizeof(src2l_vals)/sizeof(src2l_vals[0]) ; j++) { |
| 3363 | long source2_l = src2l_vals[j]; |
| 3364 | |
| 3365 | unsigned long expected_result; |
| 3366 | unsigned long result; |
| 3367 | |
| 3368 | if (source2_l <= 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip55;} |
| 3369 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 3370 | |
| 3371 | expected_result = (unsigned long) (source1_ul % source2_l); |
| 3372 | |
| 3373 | result = proc(source1_ul, source2_l); |
| 3374 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 3375 | if (expected_result != result) { |
| 3376 | printf("Failed unsigned long %% long test, expected %lu, got %lu, for %lu %% %ld\n", |
| 3377 | expected_result, result, source1_ul, source2_l); |
| 3378 | if (dumped == 0) cod_dump(gen_code); |
| 3379 | failed++; |
| 3380 | dumped++; |
| 3381 | } |
| 3382 | skip55: ; |
| 3383 | } |
| 3384 | } |
| 3385 | if (verbose) printf(" done\n"); |
| 3386 | cod_free_parse_context(context); |
| 3387 | cod_code_free(gen_code); |
| 3388 | } |
| 3389 | } |
| 3390 | void mod_l_tests() |
| 3391 | { |
| 3392 | if ((only_run_test == NULL((void*)0)) || |
| 3393 | (strcmp(only_run_test, "l%c") == 0)) { |
| 3394 | int i, j; |
| 3395 | static char code[] = "{\n\ |
| 3396 | long a = p1;\n\ |
| 3397 | signed char b = p2;\n\ |
| 3398 | return a % b;\n\ |
| 3399 | }"; |
| 3400 | |
| 3401 | long (*proc)(long a, signed char b); |
| 3402 | cod_parse_context context = new_cod_parse_context(); |
| 3403 | int dumped = 0; |
| 3404 | |
| 3405 | cod_code gen_code; |
| 3406 | |
| 3407 | /* test for long % signed char */ |
| 3408 | if (verbose) printf("test for long %% signed char"); |
| 3409 | |
| 3410 | cod_assoc_externs(context, externs); |
| 3411 | cod_parse_for_context(extern_string, context); |
| 3412 | |
| 3413 | cod_subroutine_declaration("long proc(long p1, signed char p2)", |
| 3414 | context); |
| 3415 | gen_code = cod_code_gen(code, context); |
| 3416 | proc = (long (*)(long, signed char))(long)gen_code->func; |
| 3417 | |
| 3418 | |
| 3419 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 3420 | long source1_l = src1l_vals[i]; |
| 3421 | for (j=0 ; j < sizeof(src2c_vals)/sizeof(src2c_vals[0]) ; j++) { |
| 3422 | signed char source2_c = src2c_vals[j]; |
| 3423 | |
| 3424 | long expected_result; |
| 3425 | long result; |
| 3426 | |
| 3427 | if (source2_c <= 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip56;} |
| 3428 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 3429 | |
| 3430 | expected_result = (long) (source1_l % source2_c); |
| 3431 | |
| 3432 | result = proc(source1_l, source2_c); |
| 3433 | if (expected_result != result) { |
| 3434 | printf("Failed long %% signed char test, expected %ld, got %ld, for %ld %% %d\n", |
| 3435 | expected_result, result, source1_l, source2_c); |
| 3436 | if (dumped == 0) cod_dump(gen_code); |
| 3437 | failed++; |
| 3438 | dumped++; |
| 3439 | } |
| 3440 | skip56: ; |
| 3441 | } |
| 3442 | } |
| 3443 | if (verbose) printf(" done\n"); |
| 3444 | cod_free_parse_context(context); |
| 3445 | cod_code_free(gen_code); |
| 3446 | } |
| 3447 | if ((only_run_test == NULL((void*)0)) || |
| 3448 | (strcmp(only_run_test, "l%uc") == 0)) { |
| 3449 | int i, j; |
| 3450 | static char code[] = "{\n\ |
| 3451 | long a = p1;\n\ |
| 3452 | unsigned char b = p2;\n\ |
| 3453 | return a % b;\n\ |
| 3454 | }"; |
| 3455 | |
| 3456 | long (*proc)(long a, unsigned char b); |
| 3457 | cod_parse_context context = new_cod_parse_context(); |
| 3458 | int dumped = 0; |
| 3459 | |
| 3460 | cod_code gen_code; |
| 3461 | |
| 3462 | /* test for long % unsigned char */ |
| 3463 | if (verbose) printf("test for long %% unsigned char"); |
| 3464 | |
| 3465 | cod_assoc_externs(context, externs); |
| 3466 | cod_parse_for_context(extern_string, context); |
| 3467 | |
| 3468 | cod_subroutine_declaration("long proc(long p1, unsigned char p2)", |
| 3469 | context); |
| 3470 | gen_code = cod_code_gen(code, context); |
| 3471 | proc = (long (*)(long, unsigned char))(long)gen_code->func; |
| 3472 | |
| 3473 | |
| 3474 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 3475 | long source1_l = src1l_vals[i]; |
| 3476 | for (j=0 ; j < sizeof(src2uc_vals)/sizeof(src2uc_vals[0]) ; j++) { |
| 3477 | unsigned char source2_uc = src2uc_vals[j]; |
| 3478 | |
| 3479 | long expected_result; |
| 3480 | long result; |
| 3481 | |
| 3482 | if (source2_uc <= 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip57;} |
| 3483 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 3484 | |
| 3485 | expected_result = (long) (source1_l % source2_uc); |
| 3486 | |
| 3487 | result = proc(source1_l, source2_uc); |
| 3488 | if (expected_result != result) { |
| 3489 | printf("Failed long %% unsigned char test, expected %ld, got %ld, for %ld %% %u\n", |
| 3490 | expected_result, result, source1_l, source2_uc); |
| 3491 | if (dumped == 0) cod_dump(gen_code); |
| 3492 | failed++; |
| 3493 | dumped++; |
| 3494 | } |
| 3495 | skip57: ; |
| 3496 | } |
| 3497 | } |
| 3498 | if (verbose) printf(" done\n"); |
| 3499 | cod_free_parse_context(context); |
| 3500 | cod_code_free(gen_code); |
| 3501 | } |
| 3502 | if ((only_run_test == NULL((void*)0)) || |
| 3503 | (strcmp(only_run_test, "l%s") == 0)) { |
| 3504 | int i, j; |
| 3505 | static char code[] = "{\n\ |
| 3506 | long a = p1;\n\ |
| 3507 | short b = p2;\n\ |
| 3508 | return a % b;\n\ |
| 3509 | }"; |
| 3510 | |
| 3511 | long (*proc)(long a, short b); |
| 3512 | cod_parse_context context = new_cod_parse_context(); |
| 3513 | int dumped = 0; |
| 3514 | |
| 3515 | cod_code gen_code; |
| 3516 | |
| 3517 | /* test for long % short */ |
| 3518 | if (verbose) printf("test for long %% short"); |
| 3519 | |
| 3520 | cod_assoc_externs(context, externs); |
| 3521 | cod_parse_for_context(extern_string, context); |
| 3522 | |
| 3523 | cod_subroutine_declaration("long proc(long p1, short p2)", |
| 3524 | context); |
| 3525 | gen_code = cod_code_gen(code, context); |
| 3526 | proc = (long (*)(long, short))(long)gen_code->func; |
| 3527 | |
| 3528 | |
| 3529 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 3530 | long source1_l = src1l_vals[i]; |
| 3531 | for (j=0 ; j < sizeof(src2s_vals)/sizeof(src2s_vals[0]) ; j++) { |
| 3532 | short source2_s = src2s_vals[j]; |
| 3533 | |
| 3534 | long expected_result; |
| 3535 | long result; |
| 3536 | |
| 3537 | if (source2_s <= 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip58;} |
| 3538 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 3539 | |
| 3540 | expected_result = (long) (source1_l % source2_s); |
| 3541 | |
| 3542 | result = proc(source1_l, source2_s); |
| 3543 | if (expected_result != result) { |
| 3544 | printf("Failed long %% short test, expected %ld, got %ld, for %ld %% %d\n", |
| 3545 | expected_result, result, source1_l, source2_s); |
| 3546 | if (dumped == 0) cod_dump(gen_code); |
| 3547 | failed++; |
| 3548 | dumped++; |
| 3549 | } |
| 3550 | skip58: ; |
| 3551 | } |
| 3552 | } |
| 3553 | if (verbose) printf(" done\n"); |
| 3554 | cod_free_parse_context(context); |
| 3555 | cod_code_free(gen_code); |
| 3556 | } |
| 3557 | if ((only_run_test == NULL((void*)0)) || |
| 3558 | (strcmp(only_run_test, "l%us") == 0)) { |
| 3559 | int i, j; |
| 3560 | static char code[] = "{\n\ |
| 3561 | long a = p1;\n\ |
| 3562 | unsigned short b = p2;\n\ |
| 3563 | return a % b;\n\ |
| 3564 | }"; |
| 3565 | |
| 3566 | long (*proc)(long a, unsigned short b); |
| 3567 | cod_parse_context context = new_cod_parse_context(); |
| 3568 | int dumped = 0; |
| 3569 | |
| 3570 | cod_code gen_code; |
| 3571 | |
| 3572 | /* test for long % unsigned short */ |
| 3573 | if (verbose) printf("test for long %% unsigned short"); |
| 3574 | |
| 3575 | cod_assoc_externs(context, externs); |
| 3576 | cod_parse_for_context(extern_string, context); |
| 3577 | |
| 3578 | cod_subroutine_declaration("long proc(long p1, unsigned short p2)", |
| 3579 | context); |
| 3580 | gen_code = cod_code_gen(code, context); |
| 3581 | proc = (long (*)(long, unsigned short))(long)gen_code->func; |
| 3582 | |
| 3583 | |
| 3584 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 3585 | long source1_l = src1l_vals[i]; |
| 3586 | for (j=0 ; j < sizeof(src2us_vals)/sizeof(src2us_vals[0]) ; j++) { |
| 3587 | unsigned short source2_us = src2us_vals[j]; |
| 3588 | |
| 3589 | long expected_result; |
| 3590 | long result; |
| 3591 | |
| 3592 | if (source2_us <= 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip59;} |
| 3593 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 3594 | |
| 3595 | expected_result = (long) (source1_l % source2_us); |
| 3596 | |
| 3597 | result = proc(source1_l, source2_us); |
| 3598 | if (expected_result != result) { |
| 3599 | printf("Failed long %% unsigned short test, expected %ld, got %ld, for %ld %% %u\n", |
| 3600 | expected_result, result, source1_l, source2_us); |
| 3601 | if (dumped == 0) cod_dump(gen_code); |
| 3602 | failed++; |
| 3603 | dumped++; |
| 3604 | } |
| 3605 | skip59: ; |
| 3606 | } |
| 3607 | } |
| 3608 | if (verbose) printf(" done\n"); |
| 3609 | cod_free_parse_context(context); |
| 3610 | cod_code_free(gen_code); |
| 3611 | } |
| 3612 | if ((only_run_test == NULL((void*)0)) || |
| 3613 | (strcmp(only_run_test, "l%i") == 0)) { |
| 3614 | int i, j; |
| 3615 | static char code[] = "{\n\ |
| 3616 | long a = p1;\n\ |
| 3617 | int b = p2;\n\ |
| 3618 | return a % b;\n\ |
| 3619 | }"; |
| 3620 | |
| 3621 | long (*proc)(long a, int b); |
| 3622 | cod_parse_context context = new_cod_parse_context(); |
| 3623 | int dumped = 0; |
| 3624 | |
| 3625 | cod_code gen_code; |
| 3626 | |
| 3627 | /* test for long % int */ |
| 3628 | if (verbose) printf("test for long %% int"); |
| 3629 | |
| 3630 | cod_assoc_externs(context, externs); |
| 3631 | cod_parse_for_context(extern_string, context); |
| 3632 | |
| 3633 | cod_subroutine_declaration("long proc(long p1, int p2)", |
| 3634 | context); |
| 3635 | gen_code = cod_code_gen(code, context); |
| 3636 | proc = (long (*)(long, int))(long)gen_code->func; |
| 3637 | |
| 3638 | |
| 3639 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 3640 | long source1_l = src1l_vals[i]; |
| 3641 | for (j=0 ; j < sizeof(src2i_vals)/sizeof(src2i_vals[0]) ; j++) { |
| 3642 | int source2_i = src2i_vals[j]; |
| 3643 | |
| 3644 | long expected_result; |
| 3645 | long result; |
| 3646 | |
| 3647 | if (source2_i <= 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip60;} |
| 3648 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 3649 | |
| 3650 | expected_result = (long) (source1_l % source2_i); |
| 3651 | |
| 3652 | result = proc(source1_l, source2_i); |
| 3653 | if (expected_result != result) { |
| 3654 | printf("Failed long %% int test, expected %ld, got %ld, for %ld %% %d\n", |
| 3655 | expected_result, result, source1_l, source2_i); |
| 3656 | if (dumped == 0) cod_dump(gen_code); |
| 3657 | failed++; |
| 3658 | dumped++; |
| 3659 | } |
| 3660 | skip60: ; |
| 3661 | } |
| 3662 | } |
| 3663 | if (verbose) printf(" done\n"); |
| 3664 | cod_free_parse_context(context); |
| 3665 | cod_code_free(gen_code); |
| 3666 | } |
| 3667 | if ((only_run_test == NULL((void*)0)) || |
| 3668 | (strcmp(only_run_test, "l%u") == 0)) { |
| 3669 | int i, j; |
| 3670 | static char code[] = "{\n\ |
| 3671 | long a = p1;\n\ |
| 3672 | unsigned int b = p2;\n\ |
| 3673 | return a % b;\n\ |
| 3674 | }"; |
| 3675 | |
| 3676 | long (*proc)(long a, unsigned int b); |
| 3677 | cod_parse_context context = new_cod_parse_context(); |
| 3678 | int dumped = 0; |
| 3679 | |
| 3680 | cod_code gen_code; |
| 3681 | |
| 3682 | /* test for long % unsigned int */ |
| 3683 | if (verbose) printf("test for long %% unsigned int"); |
| 3684 | |
| 3685 | cod_assoc_externs(context, externs); |
| 3686 | cod_parse_for_context(extern_string, context); |
| 3687 | |
| 3688 | cod_subroutine_declaration("long proc(long p1, unsigned int p2)", |
| 3689 | context); |
| 3690 | gen_code = cod_code_gen(code, context); |
| 3691 | proc = (long (*)(long, unsigned int))(long)gen_code->func; |
| 3692 | |
| 3693 | |
| 3694 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 3695 | long source1_l = src1l_vals[i]; |
| 3696 | for (j=0 ; j < sizeof(src2u_vals)/sizeof(src2u_vals[0]) ; j++) { |
| 3697 | unsigned int source2_u = src2u_vals[j]; |
| 3698 | |
| 3699 | long expected_result; |
| 3700 | long result; |
| 3701 | |
| 3702 | if (source2_u <= 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip61;} |
| 3703 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 3704 | |
| 3705 | expected_result = (long) (source1_l % source2_u); |
| 3706 | |
| 3707 | result = proc(source1_l, source2_u); |
| 3708 | if (expected_result != result) { |
| 3709 | printf("Failed long %% unsigned int test, expected %ld, got %ld, for %ld %% %u\n", |
| 3710 | expected_result, result, source1_l, source2_u); |
| 3711 | if (dumped == 0) cod_dump(gen_code); |
| 3712 | failed++; |
| 3713 | dumped++; |
| 3714 | } |
| 3715 | skip61: ; |
| 3716 | } |
| 3717 | } |
| 3718 | if (verbose) printf(" done\n"); |
| 3719 | cod_free_parse_context(context); |
| 3720 | cod_code_free(gen_code); |
| 3721 | } |
| 3722 | if ((only_run_test == NULL((void*)0)) || |
| 3723 | (strcmp(only_run_test, "l%ul") == 0)) { |
| 3724 | int i, j; |
| 3725 | static char code[] = "{\n\ |
| 3726 | long a = p1;\n\ |
| 3727 | unsigned long b = p2;\n\ |
| 3728 | return a % b;\n\ |
| 3729 | }"; |
| 3730 | |
| 3731 | long (*proc)(long a, unsigned long b); |
| 3732 | cod_parse_context context = new_cod_parse_context(); |
| 3733 | int dumped = 0; |
| 3734 | |
| 3735 | cod_code gen_code; |
| 3736 | |
| 3737 | /* test for long % unsigned long */ |
| 3738 | if (verbose) printf("test for long %% unsigned long"); |
| 3739 | |
| 3740 | cod_assoc_externs(context, externs); |
| 3741 | cod_parse_for_context(extern_string, context); |
| 3742 | |
| 3743 | cod_subroutine_declaration("long proc(long p1, unsigned long p2)", |
| 3744 | context); |
| 3745 | gen_code = cod_code_gen(code, context); |
| 3746 | proc = (long (*)(long, unsigned long))(long)gen_code->func; |
| 3747 | |
| 3748 | |
| 3749 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 3750 | long source1_l = src1l_vals[i]; |
| 3751 | for (j=0 ; j < sizeof(src2ul_vals)/sizeof(src2ul_vals[0]) ; j++) { |
| 3752 | unsigned long source2_ul = src2ul_vals[j]; |
| 3753 | |
| 3754 | long expected_result; |
| 3755 | long result; |
| 3756 | |
| 3757 | if (source2_ul <= 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip62;} |
| 3758 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 3759 | |
| 3760 | expected_result = (long) (source1_l % source2_ul); |
| 3761 | |
| 3762 | result = proc(source1_l, source2_ul); |
| 3763 | if (expected_result != result) { |
| 3764 | printf("Failed long %% unsigned long test, expected %ld, got %ld, for %ld %% %lu\n", |
| 3765 | expected_result, result, source1_l, source2_ul); |
| 3766 | if (dumped == 0) cod_dump(gen_code); |
| 3767 | failed++; |
| 3768 | dumped++; |
| 3769 | } |
| 3770 | skip62: ; |
| 3771 | } |
| 3772 | } |
| 3773 | if (verbose) printf(" done\n"); |
| 3774 | cod_free_parse_context(context); |
| 3775 | cod_code_free(gen_code); |
| 3776 | } |
| 3777 | if ((only_run_test == NULL((void*)0)) || |
| 3778 | (strcmp(only_run_test, "l%l") == 0)) { |
| 3779 | int i, j; |
| 3780 | static char code[] = "{\n\ |
| 3781 | long a = p1;\n\ |
| 3782 | long b = p2;\n\ |
| 3783 | return a % b;\n\ |
| 3784 | }"; |
| 3785 | |
| 3786 | long (*proc)(long a, long b); |
| 3787 | cod_parse_context context = new_cod_parse_context(); |
| 3788 | int dumped = 0; |
| 3789 | |
| 3790 | cod_code gen_code; |
| 3791 | |
| 3792 | /* test for long % long */ |
| 3793 | if (verbose) printf("test for long %% long"); |
| 3794 | |
| 3795 | cod_assoc_externs(context, externs); |
| 3796 | cod_parse_for_context(extern_string, context); |
| 3797 | |
| 3798 | cod_subroutine_declaration("long proc(long p1, long p2)", |
| 3799 | context); |
| 3800 | gen_code = cod_code_gen(code, context); |
| 3801 | proc = (long (*)(long, long))(long)gen_code->func; |
| 3802 | |
| 3803 | |
| 3804 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 3805 | long source1_l = src1l_vals[i]; |
| 3806 | for (j=0 ; j < sizeof(src2l_vals)/sizeof(src2l_vals[0]) ; j++) { |
| 3807 | long source2_l = src2l_vals[j]; |
| 3808 | |
| 3809 | long expected_result; |
| 3810 | long result; |
| 3811 | |
| 3812 | if (source2_l <= 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip63;} |
| 3813 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 3814 | |
| 3815 | expected_result = (long) (source1_l % source2_l); |
| 3816 | |
| 3817 | result = proc(source1_l, source2_l); |
| 3818 | if (expected_result != result) { |
| 3819 | printf("Failed long %% long test, expected %ld, got %ld, for %ld %% %ld\n", |
| 3820 | expected_result, result, source1_l, source2_l); |
| 3821 | if (dumped == 0) cod_dump(gen_code); |
| 3822 | failed++; |
| 3823 | dumped++; |
| 3824 | } |
| 3825 | skip63: ; |
| 3826 | } |
| 3827 | } |
| 3828 | if (verbose) printf(" done\n"); |
| 3829 | cod_free_parse_context(context); |
| 3830 | cod_code_free(gen_code); |
| 3831 | } |
| 3832 | } |
| 3833 | void and_c_tests() |
| 3834 | { |
| 3835 | if ((only_run_test == NULL((void*)0)) || |
| 3836 | (strcmp(only_run_test, "c&c") == 0)) { |
| 3837 | int i, j; |
| 3838 | static char code[] = "{\n\ |
| 3839 | signed char a = p1;\n\ |
| 3840 | signed char b = p2;\n\ |
| 3841 | return a & b;\n\ |
| 3842 | }"; |
| 3843 | |
| 3844 | signed char (*proc)(signed char a, signed char b); |
| 3845 | cod_parse_context context = new_cod_parse_context(); |
| 3846 | int dumped = 0; |
| 3847 | |
| 3848 | cod_code gen_code; |
| 3849 | |
| 3850 | /* test for signed char & signed char */ |
| 3851 | if (verbose) printf("test for signed char & signed char"); |
| 3852 | |
| 3853 | cod_assoc_externs(context, externs); |
| 3854 | cod_parse_for_context(extern_string, context); |
| 3855 | |
| 3856 | cod_subroutine_declaration("signed char proc(signed char p1, signed char p2)", |
| 3857 | context); |
| 3858 | gen_code = cod_code_gen(code, context); |
| 3859 | proc = (signed char (*)(signed char, signed char))(long)gen_code->func; |
| 3860 | |
| 3861 | |
| 3862 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 3863 | signed char source1_c = src1c_vals[i]; |
| 3864 | for (j=0 ; j < sizeof(src2c_vals)/sizeof(src2c_vals[0]) ; j++) { |
| 3865 | signed char source2_c = src2c_vals[j]; |
| 3866 | |
| 3867 | signed char expected_result; |
| 3868 | signed char result; |
| 3869 | |
| 3870 | |
| 3871 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 3872 | |
| 3873 | expected_result = (signed char) (source1_c & source2_c); |
| 3874 | |
| 3875 | result = proc(source1_c, source2_c); |
| 3876 | if (expected_result != result) { |
| 3877 | printf("Failed signed char & signed char test, expected %d, got %d, for %d & %d\n", |
| 3878 | expected_result, result, source1_c, source2_c); |
| 3879 | if (dumped == 0) cod_dump(gen_code); |
| 3880 | failed++; |
| 3881 | dumped++; |
| 3882 | } |
| 3883 | } |
| 3884 | } |
| 3885 | if (verbose) printf(" done\n"); |
| 3886 | cod_free_parse_context(context); |
| 3887 | cod_code_free(gen_code); |
| 3888 | } |
| 3889 | if ((only_run_test == NULL((void*)0)) || |
| 3890 | (strcmp(only_run_test, "c&uc") == 0)) { |
| 3891 | int i, j; |
| 3892 | static char code[] = "{\n\ |
| 3893 | signed char a = p1;\n\ |
| 3894 | unsigned char b = p2;\n\ |
| 3895 | return a & b;\n\ |
| 3896 | }"; |
| 3897 | |
| 3898 | signed char (*proc)(signed char a, unsigned char b); |
| 3899 | cod_parse_context context = new_cod_parse_context(); |
| 3900 | int dumped = 0; |
| 3901 | |
| 3902 | cod_code gen_code; |
| 3903 | |
| 3904 | /* test for signed char & unsigned char */ |
| 3905 | if (verbose) printf("test for signed char & unsigned char"); |
| 3906 | |
| 3907 | cod_assoc_externs(context, externs); |
| 3908 | cod_parse_for_context(extern_string, context); |
| 3909 | |
| 3910 | cod_subroutine_declaration("signed char proc(signed char p1, unsigned char p2)", |
| 3911 | context); |
| 3912 | gen_code = cod_code_gen(code, context); |
| 3913 | proc = (signed char (*)(signed char, unsigned char))(long)gen_code->func; |
| 3914 | |
| 3915 | |
| 3916 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 3917 | signed char source1_c = src1c_vals[i]; |
| 3918 | for (j=0 ; j < sizeof(src2uc_vals)/sizeof(src2uc_vals[0]) ; j++) { |
| 3919 | unsigned char source2_uc = src2uc_vals[j]; |
| 3920 | |
| 3921 | signed char expected_result; |
| 3922 | signed char result; |
| 3923 | |
| 3924 | |
| 3925 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 3926 | |
| 3927 | expected_result = (signed char) (source1_c & source2_uc); |
| 3928 | |
| 3929 | result = proc(source1_c, source2_uc); |
| 3930 | if (expected_result != result) { |
| 3931 | printf("Failed signed char & unsigned char test, expected %d, got %d, for %d & %u\n", |
| 3932 | expected_result, result, source1_c, source2_uc); |
| 3933 | if (dumped == 0) cod_dump(gen_code); |
| 3934 | failed++; |
| 3935 | dumped++; |
| 3936 | } |
| 3937 | } |
| 3938 | } |
| 3939 | if (verbose) printf(" done\n"); |
| 3940 | cod_free_parse_context(context); |
| 3941 | cod_code_free(gen_code); |
| 3942 | } |
| 3943 | if ((only_run_test == NULL((void*)0)) || |
| 3944 | (strcmp(only_run_test, "c&s") == 0)) { |
| 3945 | int i, j; |
| 3946 | static char code[] = "{\n\ |
| 3947 | signed char a = p1;\n\ |
| 3948 | short b = p2;\n\ |
| 3949 | return a & b;\n\ |
| 3950 | }"; |
| 3951 | |
| 3952 | signed char (*proc)(signed char a, short b); |
| 3953 | cod_parse_context context = new_cod_parse_context(); |
| 3954 | int dumped = 0; |
| 3955 | |
| 3956 | cod_code gen_code; |
| 3957 | |
| 3958 | /* test for signed char & short */ |
| 3959 | if (verbose) printf("test for signed char & short"); |
| 3960 | |
| 3961 | cod_assoc_externs(context, externs); |
| 3962 | cod_parse_for_context(extern_string, context); |
| 3963 | |
| 3964 | cod_subroutine_declaration("signed char proc(signed char p1, short p2)", |
| 3965 | context); |
| 3966 | gen_code = cod_code_gen(code, context); |
| 3967 | proc = (signed char (*)(signed char, short))(long)gen_code->func; |
| 3968 | |
| 3969 | |
| 3970 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 3971 | signed char source1_c = src1c_vals[i]; |
| 3972 | for (j=0 ; j < sizeof(src2s_vals)/sizeof(src2s_vals[0]) ; j++) { |
| 3973 | short source2_s = src2s_vals[j]; |
| 3974 | |
| 3975 | signed char expected_result; |
| 3976 | signed char result; |
| 3977 | |
| 3978 | |
| 3979 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 3980 | |
| 3981 | expected_result = (signed char) (source1_c & source2_s); |
| 3982 | |
| 3983 | result = proc(source1_c, source2_s); |
| 3984 | if (expected_result != result) { |
| 3985 | printf("Failed signed char & short test, expected %d, got %d, for %d & %d\n", |
| 3986 | expected_result, result, source1_c, source2_s); |
| 3987 | if (dumped == 0) cod_dump(gen_code); |
| 3988 | failed++; |
| 3989 | dumped++; |
| 3990 | } |
| 3991 | } |
| 3992 | } |
| 3993 | if (verbose) printf(" done\n"); |
| 3994 | cod_free_parse_context(context); |
| 3995 | cod_code_free(gen_code); |
| 3996 | } |
| 3997 | if ((only_run_test == NULL((void*)0)) || |
| 3998 | (strcmp(only_run_test, "c&us") == 0)) { |
| 3999 | int i, j; |
| 4000 | static char code[] = "{\n\ |
| 4001 | signed char a = p1;\n\ |
| 4002 | unsigned short b = p2;\n\ |
| 4003 | return a & b;\n\ |
| 4004 | }"; |
| 4005 | |
| 4006 | signed char (*proc)(signed char a, unsigned short b); |
| 4007 | cod_parse_context context = new_cod_parse_context(); |
| 4008 | int dumped = 0; |
| 4009 | |
| 4010 | cod_code gen_code; |
| 4011 | |
| 4012 | /* test for signed char & unsigned short */ |
| 4013 | if (verbose) printf("test for signed char & unsigned short"); |
| 4014 | |
| 4015 | cod_assoc_externs(context, externs); |
| 4016 | cod_parse_for_context(extern_string, context); |
| 4017 | |
| 4018 | cod_subroutine_declaration("signed char proc(signed char p1, unsigned short p2)", |
| 4019 | context); |
| 4020 | gen_code = cod_code_gen(code, context); |
| 4021 | proc = (signed char (*)(signed char, unsigned short))(long)gen_code->func; |
| 4022 | |
| 4023 | |
| 4024 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 4025 | signed char source1_c = src1c_vals[i]; |
| 4026 | for (j=0 ; j < sizeof(src2us_vals)/sizeof(src2us_vals[0]) ; j++) { |
| 4027 | unsigned short source2_us = src2us_vals[j]; |
| 4028 | |
| 4029 | signed char expected_result; |
| 4030 | signed char result; |
| 4031 | |
| 4032 | |
| 4033 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 4034 | |
| 4035 | expected_result = (signed char) (source1_c & source2_us); |
| 4036 | |
| 4037 | result = proc(source1_c, source2_us); |
| 4038 | if (expected_result != result) { |
| 4039 | printf("Failed signed char & unsigned short test, expected %d, got %d, for %d & %u\n", |
| 4040 | expected_result, result, source1_c, source2_us); |
| 4041 | if (dumped == 0) cod_dump(gen_code); |
| 4042 | failed++; |
| 4043 | dumped++; |
| 4044 | } |
| 4045 | } |
| 4046 | } |
| 4047 | if (verbose) printf(" done\n"); |
| 4048 | cod_free_parse_context(context); |
| 4049 | cod_code_free(gen_code); |
| 4050 | } |
| 4051 | if ((only_run_test == NULL((void*)0)) || |
| 4052 | (strcmp(only_run_test, "c&i") == 0)) { |
| 4053 | int i, j; |
| 4054 | static char code[] = "{\n\ |
| 4055 | signed char a = p1;\n\ |
| 4056 | int b = p2;\n\ |
| 4057 | return a & b;\n\ |
| 4058 | }"; |
| 4059 | |
| 4060 | signed char (*proc)(signed char a, int b); |
| 4061 | cod_parse_context context = new_cod_parse_context(); |
| 4062 | int dumped = 0; |
| 4063 | |
| 4064 | cod_code gen_code; |
| 4065 | |
| 4066 | /* test for signed char & int */ |
| 4067 | if (verbose) printf("test for signed char & int"); |
| 4068 | |
| 4069 | cod_assoc_externs(context, externs); |
| 4070 | cod_parse_for_context(extern_string, context); |
| 4071 | |
| 4072 | cod_subroutine_declaration("signed char proc(signed char p1, int p2)", |
| 4073 | context); |
| 4074 | gen_code = cod_code_gen(code, context); |
| 4075 | proc = (signed char (*)(signed char, int))(long)gen_code->func; |
| 4076 | |
| 4077 | |
| 4078 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 4079 | signed char source1_c = src1c_vals[i]; |
| 4080 | for (j=0 ; j < sizeof(src2i_vals)/sizeof(src2i_vals[0]) ; j++) { |
| 4081 | int source2_i = src2i_vals[j]; |
| 4082 | |
| 4083 | signed char expected_result; |
| 4084 | signed char result; |
| 4085 | |
| 4086 | |
| 4087 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 4088 | |
| 4089 | expected_result = (signed char) (source1_c & source2_i); |
| 4090 | |
| 4091 | result = proc(source1_c, source2_i); |
| 4092 | if (expected_result != result) { |
| 4093 | printf("Failed signed char & int test, expected %d, got %d, for %d & %d\n", |
| 4094 | expected_result, result, source1_c, source2_i); |
| 4095 | if (dumped == 0) cod_dump(gen_code); |
| 4096 | failed++; |
| 4097 | dumped++; |
| 4098 | } |
| 4099 | } |
| 4100 | } |
| 4101 | if (verbose) printf(" done\n"); |
| 4102 | cod_free_parse_context(context); |
| 4103 | cod_code_free(gen_code); |
| 4104 | } |
| 4105 | if ((only_run_test == NULL((void*)0)) || |
| 4106 | (strcmp(only_run_test, "c&u") == 0)) { |
| 4107 | int i, j; |
| 4108 | static char code[] = "{\n\ |
| 4109 | signed char a = p1;\n\ |
| 4110 | unsigned int b = p2;\n\ |
| 4111 | return a & b;\n\ |
| 4112 | }"; |
| 4113 | |
| 4114 | signed char (*proc)(signed char a, unsigned int b); |
| 4115 | cod_parse_context context = new_cod_parse_context(); |
| 4116 | int dumped = 0; |
| 4117 | |
| 4118 | cod_code gen_code; |
| 4119 | |
| 4120 | /* test for signed char & unsigned int */ |
| 4121 | if (verbose) printf("test for signed char & unsigned int"); |
| 4122 | |
| 4123 | cod_assoc_externs(context, externs); |
| 4124 | cod_parse_for_context(extern_string, context); |
| 4125 | |
| 4126 | cod_subroutine_declaration("signed char proc(signed char p1, unsigned int p2)", |
| 4127 | context); |
| 4128 | gen_code = cod_code_gen(code, context); |
| 4129 | proc = (signed char (*)(signed char, unsigned int))(long)gen_code->func; |
| 4130 | |
| 4131 | |
| 4132 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 4133 | signed char source1_c = src1c_vals[i]; |
| 4134 | for (j=0 ; j < sizeof(src2u_vals)/sizeof(src2u_vals[0]) ; j++) { |
| 4135 | unsigned int source2_u = src2u_vals[j]; |
| 4136 | |
| 4137 | signed char expected_result; |
| 4138 | signed char result; |
| 4139 | |
| 4140 | |
| 4141 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 4142 | |
| 4143 | expected_result = (signed char) (source1_c & source2_u); |
| 4144 | |
| 4145 | result = proc(source1_c, source2_u); |
| 4146 | if (expected_result != result) { |
| 4147 | printf("Failed signed char & unsigned int test, expected %d, got %d, for %d & %u\n", |
| 4148 | expected_result, result, source1_c, source2_u); |
| 4149 | if (dumped == 0) cod_dump(gen_code); |
| 4150 | failed++; |
| 4151 | dumped++; |
| 4152 | } |
| 4153 | } |
| 4154 | } |
| 4155 | if (verbose) printf(" done\n"); |
| 4156 | cod_free_parse_context(context); |
| 4157 | cod_code_free(gen_code); |
| 4158 | } |
| 4159 | if ((only_run_test == NULL((void*)0)) || |
| 4160 | (strcmp(only_run_test, "c&ul") == 0)) { |
| 4161 | int i, j; |
| 4162 | static char code[] = "{\n\ |
| 4163 | signed char a = p1;\n\ |
| 4164 | unsigned long b = p2;\n\ |
| 4165 | return a & b;\n\ |
| 4166 | }"; |
| 4167 | |
| 4168 | signed char (*proc)(signed char a, unsigned long b); |
| 4169 | cod_parse_context context = new_cod_parse_context(); |
| 4170 | int dumped = 0; |
| 4171 | |
| 4172 | cod_code gen_code; |
| 4173 | |
| 4174 | /* test for signed char & unsigned long */ |
| 4175 | if (verbose) printf("test for signed char & unsigned long"); |
| 4176 | |
| 4177 | cod_assoc_externs(context, externs); |
| 4178 | cod_parse_for_context(extern_string, context); |
| 4179 | |
| 4180 | cod_subroutine_declaration("signed char proc(signed char p1, unsigned long p2)", |
| 4181 | context); |
| 4182 | gen_code = cod_code_gen(code, context); |
| 4183 | proc = (signed char (*)(signed char, unsigned long))(long)gen_code->func; |
| 4184 | |
| 4185 | |
| 4186 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 4187 | signed char source1_c = src1c_vals[i]; |
| 4188 | for (j=0 ; j < sizeof(src2ul_vals)/sizeof(src2ul_vals[0]) ; j++) { |
| 4189 | unsigned long source2_ul = src2ul_vals[j]; |
| 4190 | |
| 4191 | signed char expected_result; |
| 4192 | signed char result; |
| 4193 | |
| 4194 | |
| 4195 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 4196 | |
| 4197 | expected_result = (signed char) (source1_c & source2_ul); |
| 4198 | |
| 4199 | result = proc(source1_c, source2_ul); |
| 4200 | if (expected_result != result) { |
| 4201 | printf("Failed signed char & unsigned long test, expected %d, got %d, for %d & %lu\n", |
| 4202 | expected_result, result, source1_c, source2_ul); |
| 4203 | if (dumped == 0) cod_dump(gen_code); |
| 4204 | failed++; |
| 4205 | dumped++; |
| 4206 | } |
| 4207 | } |
| 4208 | } |
| 4209 | if (verbose) printf(" done\n"); |
| 4210 | cod_free_parse_context(context); |
| 4211 | cod_code_free(gen_code); |
| 4212 | } |
| 4213 | if ((only_run_test == NULL((void*)0)) || |
| 4214 | (strcmp(only_run_test, "c&l") == 0)) { |
| 4215 | int i, j; |
| 4216 | static char code[] = "{\n\ |
| 4217 | signed char a = p1;\n\ |
| 4218 | long b = p2;\n\ |
| 4219 | return a & b;\n\ |
| 4220 | }"; |
| 4221 | |
| 4222 | signed char (*proc)(signed char a, long b); |
| 4223 | cod_parse_context context = new_cod_parse_context(); |
| 4224 | int dumped = 0; |
| 4225 | |
| 4226 | cod_code gen_code; |
| 4227 | |
| 4228 | /* test for signed char & long */ |
| 4229 | if (verbose) printf("test for signed char & long"); |
| 4230 | |
| 4231 | cod_assoc_externs(context, externs); |
| 4232 | cod_parse_for_context(extern_string, context); |
| 4233 | |
| 4234 | cod_subroutine_declaration("signed char proc(signed char p1, long p2)", |
| 4235 | context); |
| 4236 | gen_code = cod_code_gen(code, context); |
| 4237 | proc = (signed char (*)(signed char, long))(long)gen_code->func; |
| 4238 | |
| 4239 | |
| 4240 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 4241 | signed char source1_c = src1c_vals[i]; |
| 4242 | for (j=0 ; j < sizeof(src2l_vals)/sizeof(src2l_vals[0]) ; j++) { |
| 4243 | long source2_l = src2l_vals[j]; |
| 4244 | |
| 4245 | signed char expected_result; |
| 4246 | signed char result; |
| 4247 | |
| 4248 | |
| 4249 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 4250 | |
| 4251 | expected_result = (signed char) (source1_c & source2_l); |
| 4252 | |
| 4253 | result = proc(source1_c, source2_l); |
| 4254 | if (expected_result != result) { |
| 4255 | printf("Failed signed char & long test, expected %d, got %d, for %d & %ld\n", |
| 4256 | expected_result, result, source1_c, source2_l); |
| 4257 | if (dumped == 0) cod_dump(gen_code); |
| 4258 | failed++; |
| 4259 | dumped++; |
| 4260 | } |
| 4261 | } |
| 4262 | } |
| 4263 | if (verbose) printf(" done\n"); |
| 4264 | cod_free_parse_context(context); |
| 4265 | cod_code_free(gen_code); |
| 4266 | } |
| 4267 | } |
| 4268 | void and_uc_tests() |
| 4269 | { |
| 4270 | if ((only_run_test == NULL((void*)0)) || |
| 4271 | (strcmp(only_run_test, "uc&c") == 0)) { |
| 4272 | int i, j; |
| 4273 | static char code[] = "{\n\ |
| 4274 | unsigned char a = p1;\n\ |
| 4275 | signed char b = p2;\n\ |
| 4276 | return a & b;\n\ |
| 4277 | }"; |
| 4278 | |
| 4279 | unsigned char (*proc)(unsigned char a, signed char b); |
| 4280 | cod_parse_context context = new_cod_parse_context(); |
| 4281 | int dumped = 0; |
| 4282 | |
| 4283 | cod_code gen_code; |
| 4284 | |
| 4285 | /* test for unsigned char & signed char */ |
| 4286 | if (verbose) printf("test for unsigned char & signed char"); |
| 4287 | |
| 4288 | cod_assoc_externs(context, externs); |
| 4289 | cod_parse_for_context(extern_string, context); |
| 4290 | |
| 4291 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, signed char p2)", |
| 4292 | context); |
| 4293 | gen_code = cod_code_gen(code, context); |
| 4294 | proc = (unsigned char (*)(unsigned char, signed char))(long)gen_code->func; |
| 4295 | |
| 4296 | |
| 4297 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 4298 | unsigned char source1_uc = src1uc_vals[i]; |
| 4299 | for (j=0 ; j < sizeof(src2c_vals)/sizeof(src2c_vals[0]) ; j++) { |
| 4300 | signed char source2_c = src2c_vals[j]; |
| 4301 | |
| 4302 | unsigned char expected_result; |
| 4303 | unsigned char result; |
| 4304 | |
| 4305 | |
| 4306 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 4307 | |
| 4308 | expected_result = (unsigned char) (source1_uc & source2_c); |
| 4309 | |
| 4310 | result = proc(source1_uc, source2_c); |
| 4311 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 4312 | if (expected_result != result) { |
| 4313 | printf("Failed unsigned char & signed char test, expected %u, got %u, for %u & %d\n", |
| 4314 | expected_result, result, source1_uc, source2_c); |
| 4315 | if (dumped == 0) cod_dump(gen_code); |
| 4316 | failed++; |
| 4317 | dumped++; |
| 4318 | } |
| 4319 | } |
| 4320 | } |
| 4321 | if (verbose) printf(" done\n"); |
| 4322 | cod_free_parse_context(context); |
| 4323 | cod_code_free(gen_code); |
| 4324 | } |
| 4325 | if ((only_run_test == NULL((void*)0)) || |
| 4326 | (strcmp(only_run_test, "uc&uc") == 0)) { |
| 4327 | int i, j; |
| 4328 | static char code[] = "{\n\ |
| 4329 | unsigned char a = p1;\n\ |
| 4330 | unsigned char b = p2;\n\ |
| 4331 | return a & b;\n\ |
| 4332 | }"; |
| 4333 | |
| 4334 | unsigned char (*proc)(unsigned char a, unsigned char b); |
| 4335 | cod_parse_context context = new_cod_parse_context(); |
| 4336 | int dumped = 0; |
| 4337 | |
| 4338 | cod_code gen_code; |
| 4339 | |
| 4340 | /* test for unsigned char & unsigned char */ |
| 4341 | if (verbose) printf("test for unsigned char & unsigned char"); |
| 4342 | |
| 4343 | cod_assoc_externs(context, externs); |
| 4344 | cod_parse_for_context(extern_string, context); |
| 4345 | |
| 4346 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, unsigned char p2)", |
| 4347 | context); |
| 4348 | gen_code = cod_code_gen(code, context); |
| 4349 | proc = (unsigned char (*)(unsigned char, unsigned char))(long)gen_code->func; |
| 4350 | |
| 4351 | |
| 4352 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 4353 | unsigned char source1_uc = src1uc_vals[i]; |
| 4354 | for (j=0 ; j < sizeof(src2uc_vals)/sizeof(src2uc_vals[0]) ; j++) { |
| 4355 | unsigned char source2_uc = src2uc_vals[j]; |
| 4356 | |
| 4357 | unsigned char expected_result; |
| 4358 | unsigned char result; |
| 4359 | |
| 4360 | |
| 4361 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 4362 | |
| 4363 | expected_result = (unsigned char) (source1_uc & source2_uc); |
| 4364 | |
| 4365 | result = proc(source1_uc, source2_uc); |
| 4366 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 4367 | if (expected_result != result) { |
| 4368 | printf("Failed unsigned char & unsigned char test, expected %u, got %u, for %u & %u\n", |
| 4369 | expected_result, result, source1_uc, source2_uc); |
| 4370 | if (dumped == 0) cod_dump(gen_code); |
| 4371 | failed++; |
| 4372 | dumped++; |
| 4373 | } |
| 4374 | } |
| 4375 | } |
| 4376 | if (verbose) printf(" done\n"); |
| 4377 | cod_free_parse_context(context); |
| 4378 | cod_code_free(gen_code); |
| 4379 | } |
| 4380 | if ((only_run_test == NULL((void*)0)) || |
| 4381 | (strcmp(only_run_test, "uc&s") == 0)) { |
| 4382 | int i, j; |
| 4383 | static char code[] = "{\n\ |
| 4384 | unsigned char a = p1;\n\ |
| 4385 | short b = p2;\n\ |
| 4386 | return a & b;\n\ |
| 4387 | }"; |
| 4388 | |
| 4389 | unsigned char (*proc)(unsigned char a, short b); |
| 4390 | cod_parse_context context = new_cod_parse_context(); |
| 4391 | int dumped = 0; |
| 4392 | |
| 4393 | cod_code gen_code; |
| 4394 | |
| 4395 | /* test for unsigned char & short */ |
| 4396 | if (verbose) printf("test for unsigned char & short"); |
| 4397 | |
| 4398 | cod_assoc_externs(context, externs); |
| 4399 | cod_parse_for_context(extern_string, context); |
| 4400 | |
| 4401 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, short p2)", |
| 4402 | context); |
| 4403 | gen_code = cod_code_gen(code, context); |
| 4404 | proc = (unsigned char (*)(unsigned char, short))(long)gen_code->func; |
| 4405 | |
| 4406 | |
| 4407 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 4408 | unsigned char source1_uc = src1uc_vals[i]; |
| 4409 | for (j=0 ; j < sizeof(src2s_vals)/sizeof(src2s_vals[0]) ; j++) { |
| 4410 | short source2_s = src2s_vals[j]; |
| 4411 | |
| 4412 | unsigned char expected_result; |
| 4413 | unsigned char result; |
| 4414 | |
| 4415 | |
| 4416 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 4417 | |
| 4418 | expected_result = (unsigned char) (source1_uc & source2_s); |
| 4419 | |
| 4420 | result = proc(source1_uc, source2_s); |
| 4421 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 4422 | if (expected_result != result) { |
| 4423 | printf("Failed unsigned char & short test, expected %u, got %u, for %u & %d\n", |
| 4424 | expected_result, result, source1_uc, source2_s); |
| 4425 | if (dumped == 0) cod_dump(gen_code); |
| 4426 | failed++; |
| 4427 | dumped++; |
| 4428 | } |
| 4429 | } |
| 4430 | } |
| 4431 | if (verbose) printf(" done\n"); |
| 4432 | cod_free_parse_context(context); |
| 4433 | cod_code_free(gen_code); |
| 4434 | } |
| 4435 | if ((only_run_test == NULL((void*)0)) || |
| 4436 | (strcmp(only_run_test, "uc&us") == 0)) { |
| 4437 | int i, j; |
| 4438 | static char code[] = "{\n\ |
| 4439 | unsigned char a = p1;\n\ |
| 4440 | unsigned short b = p2;\n\ |
| 4441 | return a & b;\n\ |
| 4442 | }"; |
| 4443 | |
| 4444 | unsigned char (*proc)(unsigned char a, unsigned short b); |
| 4445 | cod_parse_context context = new_cod_parse_context(); |
| 4446 | int dumped = 0; |
| 4447 | |
| 4448 | cod_code gen_code; |
| 4449 | |
| 4450 | /* test for unsigned char & unsigned short */ |
| 4451 | if (verbose) printf("test for unsigned char & unsigned short"); |
| 4452 | |
| 4453 | cod_assoc_externs(context, externs); |
| 4454 | cod_parse_for_context(extern_string, context); |
| 4455 | |
| 4456 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, unsigned short p2)", |
| 4457 | context); |
| 4458 | gen_code = cod_code_gen(code, context); |
| 4459 | proc = (unsigned char (*)(unsigned char, unsigned short))(long)gen_code->func; |
| 4460 | |
| 4461 | |
| 4462 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 4463 | unsigned char source1_uc = src1uc_vals[i]; |
| 4464 | for (j=0 ; j < sizeof(src2us_vals)/sizeof(src2us_vals[0]) ; j++) { |
| 4465 | unsigned short source2_us = src2us_vals[j]; |
| 4466 | |
| 4467 | unsigned char expected_result; |
| 4468 | unsigned char result; |
| 4469 | |
| 4470 | |
| 4471 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 4472 | |
| 4473 | expected_result = (unsigned char) (source1_uc & source2_us); |
| 4474 | |
| 4475 | result = proc(source1_uc, source2_us); |
| 4476 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 4477 | if (expected_result != result) { |
| 4478 | printf("Failed unsigned char & unsigned short test, expected %u, got %u, for %u & %u\n", |
| 4479 | expected_result, result, source1_uc, source2_us); |
| 4480 | if (dumped == 0) cod_dump(gen_code); |
| 4481 | failed++; |
| 4482 | dumped++; |
| 4483 | } |
| 4484 | } |
| 4485 | } |
| 4486 | if (verbose) printf(" done\n"); |
| 4487 | cod_free_parse_context(context); |
| 4488 | cod_code_free(gen_code); |
| 4489 | } |
| 4490 | if ((only_run_test == NULL((void*)0)) || |
| 4491 | (strcmp(only_run_test, "uc&i") == 0)) { |
| 4492 | int i, j; |
| 4493 | static char code[] = "{\n\ |
| 4494 | unsigned char a = p1;\n\ |
| 4495 | int b = p2;\n\ |
| 4496 | return a & b;\n\ |
| 4497 | }"; |
| 4498 | |
| 4499 | unsigned char (*proc)(unsigned char a, int b); |
| 4500 | cod_parse_context context = new_cod_parse_context(); |
| 4501 | int dumped = 0; |
| 4502 | |
| 4503 | cod_code gen_code; |
| 4504 | |
| 4505 | /* test for unsigned char & int */ |
| 4506 | if (verbose) printf("test for unsigned char & int"); |
| 4507 | |
| 4508 | cod_assoc_externs(context, externs); |
| 4509 | cod_parse_for_context(extern_string, context); |
| 4510 | |
| 4511 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, int p2)", |
| 4512 | context); |
| 4513 | gen_code = cod_code_gen(code, context); |
| 4514 | proc = (unsigned char (*)(unsigned char, int))(long)gen_code->func; |
| 4515 | |
| 4516 | |
| 4517 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 4518 | unsigned char source1_uc = src1uc_vals[i]; |
| 4519 | for (j=0 ; j < sizeof(src2i_vals)/sizeof(src2i_vals[0]) ; j++) { |
| 4520 | int source2_i = src2i_vals[j]; |
| 4521 | |
| 4522 | unsigned char expected_result; |
| 4523 | unsigned char result; |
| 4524 | |
| 4525 | |
| 4526 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 4527 | |
| 4528 | expected_result = (unsigned char) (source1_uc & source2_i); |
| 4529 | |
| 4530 | result = proc(source1_uc, source2_i); |
| 4531 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 4532 | if (expected_result != result) { |
| 4533 | printf("Failed unsigned char & int test, expected %u, got %u, for %u & %d\n", |
| 4534 | expected_result, result, source1_uc, source2_i); |
| 4535 | if (dumped == 0) cod_dump(gen_code); |
| 4536 | failed++; |
| 4537 | dumped++; |
| 4538 | } |
| 4539 | } |
| 4540 | } |
| 4541 | if (verbose) printf(" done\n"); |
| 4542 | cod_free_parse_context(context); |
| 4543 | cod_code_free(gen_code); |
| 4544 | } |
| 4545 | if ((only_run_test == NULL((void*)0)) || |
| 4546 | (strcmp(only_run_test, "uc&u") == 0)) { |
| 4547 | int i, j; |
| 4548 | static char code[] = "{\n\ |
| 4549 | unsigned char a = p1;\n\ |
| 4550 | unsigned int b = p2;\n\ |
| 4551 | return a & b;\n\ |
| 4552 | }"; |
| 4553 | |
| 4554 | unsigned char (*proc)(unsigned char a, unsigned int b); |
| 4555 | cod_parse_context context = new_cod_parse_context(); |
| 4556 | int dumped = 0; |
| 4557 | |
| 4558 | cod_code gen_code; |
| 4559 | |
| 4560 | /* test for unsigned char & unsigned int */ |
| 4561 | if (verbose) printf("test for unsigned char & unsigned int"); |
| 4562 | |
| 4563 | cod_assoc_externs(context, externs); |
| 4564 | cod_parse_for_context(extern_string, context); |
| 4565 | |
| 4566 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, unsigned int p2)", |
| 4567 | context); |
| 4568 | gen_code = cod_code_gen(code, context); |
| 4569 | proc = (unsigned char (*)(unsigned char, unsigned int))(long)gen_code->func; |
| 4570 | |
| 4571 | |
| 4572 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 4573 | unsigned char source1_uc = src1uc_vals[i]; |
| 4574 | for (j=0 ; j < sizeof(src2u_vals)/sizeof(src2u_vals[0]) ; j++) { |
| 4575 | unsigned int source2_u = src2u_vals[j]; |
| 4576 | |
| 4577 | unsigned char expected_result; |
| 4578 | unsigned char result; |
| 4579 | |
| 4580 | |
| 4581 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 4582 | |
| 4583 | expected_result = (unsigned char) (source1_uc & source2_u); |
| 4584 | |
| 4585 | result = proc(source1_uc, source2_u); |
| 4586 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 4587 | if (expected_result != result) { |
| 4588 | printf("Failed unsigned char & unsigned int test, expected %u, got %u, for %u & %u\n", |
| 4589 | expected_result, result, source1_uc, source2_u); |
| 4590 | if (dumped == 0) cod_dump(gen_code); |
| 4591 | failed++; |
| 4592 | dumped++; |
| 4593 | } |
| 4594 | } |
| 4595 | } |
| 4596 | if (verbose) printf(" done\n"); |
| 4597 | cod_free_parse_context(context); |
| 4598 | cod_code_free(gen_code); |
| 4599 | } |
| 4600 | if ((only_run_test == NULL((void*)0)) || |
| 4601 | (strcmp(only_run_test, "uc&ul") == 0)) { |
| 4602 | int i, j; |
| 4603 | static char code[] = "{\n\ |
| 4604 | unsigned char a = p1;\n\ |
| 4605 | unsigned long b = p2;\n\ |
| 4606 | return a & b;\n\ |
| 4607 | }"; |
| 4608 | |
| 4609 | unsigned char (*proc)(unsigned char a, unsigned long b); |
| 4610 | cod_parse_context context = new_cod_parse_context(); |
| 4611 | int dumped = 0; |
| 4612 | |
| 4613 | cod_code gen_code; |
| 4614 | |
| 4615 | /* test for unsigned char & unsigned long */ |
| 4616 | if (verbose) printf("test for unsigned char & unsigned long"); |
| 4617 | |
| 4618 | cod_assoc_externs(context, externs); |
| 4619 | cod_parse_for_context(extern_string, context); |
| 4620 | |
| 4621 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, unsigned long p2)", |
| 4622 | context); |
| 4623 | gen_code = cod_code_gen(code, context); |
| 4624 | proc = (unsigned char (*)(unsigned char, unsigned long))(long)gen_code->func; |
| 4625 | |
| 4626 | |
| 4627 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 4628 | unsigned char source1_uc = src1uc_vals[i]; |
| 4629 | for (j=0 ; j < sizeof(src2ul_vals)/sizeof(src2ul_vals[0]) ; j++) { |
| 4630 | unsigned long source2_ul = src2ul_vals[j]; |
| 4631 | |
| 4632 | unsigned char expected_result; |
| 4633 | unsigned char result; |
| 4634 | |
| 4635 | |
| 4636 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 4637 | |
| 4638 | expected_result = (unsigned char) (source1_uc & source2_ul); |
| 4639 | |
| 4640 | result = proc(source1_uc, source2_ul); |
| 4641 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 4642 | if (expected_result != result) { |
| 4643 | printf("Failed unsigned char & unsigned long test, expected %u, got %u, for %u & %lu\n", |
| 4644 | expected_result, result, source1_uc, source2_ul); |
| 4645 | if (dumped == 0) cod_dump(gen_code); |
| 4646 | failed++; |
| 4647 | dumped++; |
| 4648 | } |
| 4649 | } |
| 4650 | } |
| 4651 | if (verbose) printf(" done\n"); |
| 4652 | cod_free_parse_context(context); |
| 4653 | cod_code_free(gen_code); |
| 4654 | } |
| 4655 | if ((only_run_test == NULL((void*)0)) || |
| 4656 | (strcmp(only_run_test, "uc&l") == 0)) { |
| 4657 | int i, j; |
| 4658 | static char code[] = "{\n\ |
| 4659 | unsigned char a = p1;\n\ |
| 4660 | long b = p2;\n\ |
| 4661 | return a & b;\n\ |
| 4662 | }"; |
| 4663 | |
| 4664 | unsigned char (*proc)(unsigned char a, long b); |
| 4665 | cod_parse_context context = new_cod_parse_context(); |
| 4666 | int dumped = 0; |
| 4667 | |
| 4668 | cod_code gen_code; |
| 4669 | |
| 4670 | /* test for unsigned char & long */ |
| 4671 | if (verbose) printf("test for unsigned char & long"); |
| 4672 | |
| 4673 | cod_assoc_externs(context, externs); |
| 4674 | cod_parse_for_context(extern_string, context); |
| 4675 | |
| 4676 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, long p2)", |
| 4677 | context); |
| 4678 | gen_code = cod_code_gen(code, context); |
| 4679 | proc = (unsigned char (*)(unsigned char, long))(long)gen_code->func; |
| 4680 | |
| 4681 | |
| 4682 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 4683 | unsigned char source1_uc = src1uc_vals[i]; |
| 4684 | for (j=0 ; j < sizeof(src2l_vals)/sizeof(src2l_vals[0]) ; j++) { |
| 4685 | long source2_l = src2l_vals[j]; |
| 4686 | |
| 4687 | unsigned char expected_result; |
| 4688 | unsigned char result; |
| 4689 | |
| 4690 | |
| 4691 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 4692 | |
| 4693 | expected_result = (unsigned char) (source1_uc & source2_l); |
| 4694 | |
| 4695 | result = proc(source1_uc, source2_l); |
| 4696 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 4697 | if (expected_result != result) { |
| 4698 | printf("Failed unsigned char & long test, expected %u, got %u, for %u & %ld\n", |
| 4699 | expected_result, result, source1_uc, source2_l); |
| 4700 | if (dumped == 0) cod_dump(gen_code); |
| 4701 | failed++; |
| 4702 | dumped++; |
| 4703 | } |
| 4704 | } |
| 4705 | } |
| 4706 | if (verbose) printf(" done\n"); |
| 4707 | cod_free_parse_context(context); |
| 4708 | cod_code_free(gen_code); |
| 4709 | } |
| 4710 | } |
| 4711 | void and_s_tests() |
| 4712 | { |
| 4713 | if ((only_run_test == NULL((void*)0)) || |
| 4714 | (strcmp(only_run_test, "s&c") == 0)) { |
| 4715 | int i, j; |
| 4716 | static char code[] = "{\n\ |
| 4717 | short a = p1;\n\ |
| 4718 | signed char b = p2;\n\ |
| 4719 | return a & b;\n\ |
| 4720 | }"; |
| 4721 | |
| 4722 | short (*proc)(short a, signed char b); |
| 4723 | cod_parse_context context = new_cod_parse_context(); |
| 4724 | int dumped = 0; |
| 4725 | |
| 4726 | cod_code gen_code; |
| 4727 | |
| 4728 | /* test for short & signed char */ |
| 4729 | if (verbose) printf("test for short & signed char"); |
| 4730 | |
| 4731 | cod_assoc_externs(context, externs); |
| 4732 | cod_parse_for_context(extern_string, context); |
| 4733 | |
| 4734 | cod_subroutine_declaration("short proc(short p1, signed char p2)", |
| 4735 | context); |
| 4736 | gen_code = cod_code_gen(code, context); |
| 4737 | proc = (short (*)(short, signed char))(long)gen_code->func; |
| 4738 | |
| 4739 | |
| 4740 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 4741 | short source1_s = src1s_vals[i]; |
| 4742 | for (j=0 ; j < sizeof(src2c_vals)/sizeof(src2c_vals[0]) ; j++) { |
| 4743 | signed char source2_c = src2c_vals[j]; |
| 4744 | |
| 4745 | short expected_result; |
| 4746 | short result; |
| 4747 | |
| 4748 | |
| 4749 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 4750 | |
| 4751 | expected_result = (short) (source1_s & source2_c); |
| 4752 | |
| 4753 | result = proc(source1_s, source2_c); |
| 4754 | if (expected_result != result) { |
| 4755 | printf("Failed short & signed char test, expected %d, got %d, for %d & %d\n", |
| 4756 | expected_result, result, source1_s, source2_c); |
| 4757 | if (dumped == 0) cod_dump(gen_code); |
| 4758 | failed++; |
| 4759 | dumped++; |
| 4760 | } |
| 4761 | } |
| 4762 | } |
| 4763 | if (verbose) printf(" done\n"); |
| 4764 | cod_free_parse_context(context); |
| 4765 | cod_code_free(gen_code); |
| 4766 | } |
| 4767 | if ((only_run_test == NULL((void*)0)) || |
| 4768 | (strcmp(only_run_test, "s&uc") == 0)) { |
| 4769 | int i, j; |
| 4770 | static char code[] = "{\n\ |
| 4771 | short a = p1;\n\ |
| 4772 | unsigned char b = p2;\n\ |
| 4773 | return a & b;\n\ |
| 4774 | }"; |
| 4775 | |
| 4776 | short (*proc)(short a, unsigned char b); |
| 4777 | cod_parse_context context = new_cod_parse_context(); |
| 4778 | int dumped = 0; |
| 4779 | |
| 4780 | cod_code gen_code; |
| 4781 | |
| 4782 | /* test for short & unsigned char */ |
| 4783 | if (verbose) printf("test for short & unsigned char"); |
| 4784 | |
| 4785 | cod_assoc_externs(context, externs); |
| 4786 | cod_parse_for_context(extern_string, context); |
| 4787 | |
| 4788 | cod_subroutine_declaration("short proc(short p1, unsigned char p2)", |
| 4789 | context); |
| 4790 | gen_code = cod_code_gen(code, context); |
| 4791 | proc = (short (*)(short, unsigned char))(long)gen_code->func; |
| 4792 | |
| 4793 | |
| 4794 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 4795 | short source1_s = src1s_vals[i]; |
| 4796 | for (j=0 ; j < sizeof(src2uc_vals)/sizeof(src2uc_vals[0]) ; j++) { |
| 4797 | unsigned char source2_uc = src2uc_vals[j]; |
| 4798 | |
| 4799 | short expected_result; |
| 4800 | short result; |
| 4801 | |
| 4802 | |
| 4803 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 4804 | |
| 4805 | expected_result = (short) (source1_s & source2_uc); |
| 4806 | |
| 4807 | result = proc(source1_s, source2_uc); |
| 4808 | if (expected_result != result) { |
| 4809 | printf("Failed short & unsigned char test, expected %d, got %d, for %d & %u\n", |
| 4810 | expected_result, result, source1_s, source2_uc); |
| 4811 | if (dumped == 0) cod_dump(gen_code); |
| 4812 | failed++; |
| 4813 | dumped++; |
| 4814 | } |
| 4815 | } |
| 4816 | } |
| 4817 | if (verbose) printf(" done\n"); |
| 4818 | cod_free_parse_context(context); |
| 4819 | cod_code_free(gen_code); |
| 4820 | } |
| 4821 | if ((only_run_test == NULL((void*)0)) || |
| 4822 | (strcmp(only_run_test, "s&s") == 0)) { |
| 4823 | int i, j; |
| 4824 | static char code[] = "{\n\ |
| 4825 | short a = p1;\n\ |
| 4826 | short b = p2;\n\ |
| 4827 | return a & b;\n\ |
| 4828 | }"; |
| 4829 | |
| 4830 | short (*proc)(short a, short b); |
| 4831 | cod_parse_context context = new_cod_parse_context(); |
| 4832 | int dumped = 0; |
| 4833 | |
| 4834 | cod_code gen_code; |
| 4835 | |
| 4836 | /* test for short & short */ |
| 4837 | if (verbose) printf("test for short & short"); |
| 4838 | |
| 4839 | cod_assoc_externs(context, externs); |
| 4840 | cod_parse_for_context(extern_string, context); |
| 4841 | |
| 4842 | cod_subroutine_declaration("short proc(short p1, short p2)", |
| 4843 | context); |
| 4844 | gen_code = cod_code_gen(code, context); |
| 4845 | proc = (short (*)(short, short))(long)gen_code->func; |
| 4846 | |
| 4847 | |
| 4848 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 4849 | short source1_s = src1s_vals[i]; |
| 4850 | for (j=0 ; j < sizeof(src2s_vals)/sizeof(src2s_vals[0]) ; j++) { |
| 4851 | short source2_s = src2s_vals[j]; |
| 4852 | |
| 4853 | short expected_result; |
| 4854 | short result; |
| 4855 | |
| 4856 | |
| 4857 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 4858 | |
| 4859 | expected_result = (short) (source1_s & source2_s); |
| 4860 | |
| 4861 | result = proc(source1_s, source2_s); |
| 4862 | if (expected_result != result) { |
| 4863 | printf("Failed short & short test, expected %d, got %d, for %d & %d\n", |
| 4864 | expected_result, result, source1_s, source2_s); |
| 4865 | if (dumped == 0) cod_dump(gen_code); |
| 4866 | failed++; |
| 4867 | dumped++; |
| 4868 | } |
| 4869 | } |
| 4870 | } |
| 4871 | if (verbose) printf(" done\n"); |
| 4872 | cod_free_parse_context(context); |
| 4873 | cod_code_free(gen_code); |
| 4874 | } |
| 4875 | if ((only_run_test == NULL((void*)0)) || |
| 4876 | (strcmp(only_run_test, "s&us") == 0)) { |
| 4877 | int i, j; |
| 4878 | static char code[] = "{\n\ |
| 4879 | short a = p1;\n\ |
| 4880 | unsigned short b = p2;\n\ |
| 4881 | return a & b;\n\ |
| 4882 | }"; |
| 4883 | |
| 4884 | short (*proc)(short a, unsigned short b); |
| 4885 | cod_parse_context context = new_cod_parse_context(); |
| 4886 | int dumped = 0; |
| 4887 | |
| 4888 | cod_code gen_code; |
| 4889 | |
| 4890 | /* test for short & unsigned short */ |
| 4891 | if (verbose) printf("test for short & unsigned short"); |
| 4892 | |
| 4893 | cod_assoc_externs(context, externs); |
| 4894 | cod_parse_for_context(extern_string, context); |
| 4895 | |
| 4896 | cod_subroutine_declaration("short proc(short p1, unsigned short p2)", |
| 4897 | context); |
| 4898 | gen_code = cod_code_gen(code, context); |
| 4899 | proc = (short (*)(short, unsigned short))(long)gen_code->func; |
| 4900 | |
| 4901 | |
| 4902 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 4903 | short source1_s = src1s_vals[i]; |
| 4904 | for (j=0 ; j < sizeof(src2us_vals)/sizeof(src2us_vals[0]) ; j++) { |
| 4905 | unsigned short source2_us = src2us_vals[j]; |
| 4906 | |
| 4907 | short expected_result; |
| 4908 | short result; |
| 4909 | |
| 4910 | |
| 4911 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 4912 | |
| 4913 | expected_result = (short) (source1_s & source2_us); |
| 4914 | |
| 4915 | result = proc(source1_s, source2_us); |
| 4916 | if (expected_result != result) { |
| 4917 | printf("Failed short & unsigned short test, expected %d, got %d, for %d & %u\n", |
| 4918 | expected_result, result, source1_s, source2_us); |
| 4919 | if (dumped == 0) cod_dump(gen_code); |
| 4920 | failed++; |
| 4921 | dumped++; |
| 4922 | } |
| 4923 | } |
| 4924 | } |
| 4925 | if (verbose) printf(" done\n"); |
| 4926 | cod_free_parse_context(context); |
| 4927 | cod_code_free(gen_code); |
| 4928 | } |
| 4929 | if ((only_run_test == NULL((void*)0)) || |
| 4930 | (strcmp(only_run_test, "s&i") == 0)) { |
| 4931 | int i, j; |
| 4932 | static char code[] = "{\n\ |
| 4933 | short a = p1;\n\ |
| 4934 | int b = p2;\n\ |
| 4935 | return a & b;\n\ |
| 4936 | }"; |
| 4937 | |
| 4938 | short (*proc)(short a, int b); |
| 4939 | cod_parse_context context = new_cod_parse_context(); |
| 4940 | int dumped = 0; |
| 4941 | |
| 4942 | cod_code gen_code; |
| 4943 | |
| 4944 | /* test for short & int */ |
| 4945 | if (verbose) printf("test for short & int"); |
| 4946 | |
| 4947 | cod_assoc_externs(context, externs); |
| 4948 | cod_parse_for_context(extern_string, context); |
| 4949 | |
| 4950 | cod_subroutine_declaration("short proc(short p1, int p2)", |
| 4951 | context); |
| 4952 | gen_code = cod_code_gen(code, context); |
| 4953 | proc = (short (*)(short, int))(long)gen_code->func; |
| 4954 | |
| 4955 | |
| 4956 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 4957 | short source1_s = src1s_vals[i]; |
| 4958 | for (j=0 ; j < sizeof(src2i_vals)/sizeof(src2i_vals[0]) ; j++) { |
| 4959 | int source2_i = src2i_vals[j]; |
| 4960 | |
| 4961 | short expected_result; |
| 4962 | short result; |
| 4963 | |
| 4964 | |
| 4965 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 4966 | |
| 4967 | expected_result = (short) (source1_s & source2_i); |
| 4968 | |
| 4969 | result = proc(source1_s, source2_i); |
| 4970 | if (expected_result != result) { |
| 4971 | printf("Failed short & int test, expected %d, got %d, for %d & %d\n", |
| 4972 | expected_result, result, source1_s, source2_i); |
| 4973 | if (dumped == 0) cod_dump(gen_code); |
| 4974 | failed++; |
| 4975 | dumped++; |
| 4976 | } |
| 4977 | } |
| 4978 | } |
| 4979 | if (verbose) printf(" done\n"); |
| 4980 | cod_free_parse_context(context); |
| 4981 | cod_code_free(gen_code); |
| 4982 | } |
| 4983 | if ((only_run_test == NULL((void*)0)) || |
| 4984 | (strcmp(only_run_test, "s&u") == 0)) { |
| 4985 | int i, j; |
| 4986 | static char code[] = "{\n\ |
| 4987 | short a = p1;\n\ |
| 4988 | unsigned int b = p2;\n\ |
| 4989 | return a & b;\n\ |
| 4990 | }"; |
| 4991 | |
| 4992 | short (*proc)(short a, unsigned int b); |
| 4993 | cod_parse_context context = new_cod_parse_context(); |
| 4994 | int dumped = 0; |
| 4995 | |
| 4996 | cod_code gen_code; |
| 4997 | |
| 4998 | /* test for short & unsigned int */ |
| 4999 | if (verbose) printf("test for short & unsigned int"); |
| 5000 | |
| 5001 | cod_assoc_externs(context, externs); |
| 5002 | cod_parse_for_context(extern_string, context); |
| 5003 | |
| 5004 | cod_subroutine_declaration("short proc(short p1, unsigned int p2)", |
| 5005 | context); |
| 5006 | gen_code = cod_code_gen(code, context); |
| 5007 | proc = (short (*)(short, unsigned int))(long)gen_code->func; |
| 5008 | |
| 5009 | |
| 5010 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 5011 | short source1_s = src1s_vals[i]; |
| 5012 | for (j=0 ; j < sizeof(src2u_vals)/sizeof(src2u_vals[0]) ; j++) { |
| 5013 | unsigned int source2_u = src2u_vals[j]; |
| 5014 | |
| 5015 | short expected_result; |
| 5016 | short result; |
| 5017 | |
| 5018 | |
| 5019 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 5020 | |
| 5021 | expected_result = (short) (source1_s & source2_u); |
| 5022 | |
| 5023 | result = proc(source1_s, source2_u); |
| 5024 | if (expected_result != result) { |
| 5025 | printf("Failed short & unsigned int test, expected %d, got %d, for %d & %u\n", |
| 5026 | expected_result, result, source1_s, source2_u); |
| 5027 | if (dumped == 0) cod_dump(gen_code); |
| 5028 | failed++; |
| 5029 | dumped++; |
| 5030 | } |
| 5031 | } |
| 5032 | } |
| 5033 | if (verbose) printf(" done\n"); |
| 5034 | cod_free_parse_context(context); |
| 5035 | cod_code_free(gen_code); |
| 5036 | } |
| 5037 | if ((only_run_test == NULL((void*)0)) || |
| 5038 | (strcmp(only_run_test, "s&ul") == 0)) { |
| 5039 | int i, j; |
| 5040 | static char code[] = "{\n\ |
| 5041 | short a = p1;\n\ |
| 5042 | unsigned long b = p2;\n\ |
| 5043 | return a & b;\n\ |
| 5044 | }"; |
| 5045 | |
| 5046 | short (*proc)(short a, unsigned long b); |
| 5047 | cod_parse_context context = new_cod_parse_context(); |
| 5048 | int dumped = 0; |
| 5049 | |
| 5050 | cod_code gen_code; |
| 5051 | |
| 5052 | /* test for short & unsigned long */ |
| 5053 | if (verbose) printf("test for short & unsigned long"); |
| 5054 | |
| 5055 | cod_assoc_externs(context, externs); |
| 5056 | cod_parse_for_context(extern_string, context); |
| 5057 | |
| 5058 | cod_subroutine_declaration("short proc(short p1, unsigned long p2)", |
| 5059 | context); |
| 5060 | gen_code = cod_code_gen(code, context); |
| 5061 | proc = (short (*)(short, unsigned long))(long)gen_code->func; |
| 5062 | |
| 5063 | |
| 5064 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 5065 | short source1_s = src1s_vals[i]; |
| 5066 | for (j=0 ; j < sizeof(src2ul_vals)/sizeof(src2ul_vals[0]) ; j++) { |
| 5067 | unsigned long source2_ul = src2ul_vals[j]; |
| 5068 | |
| 5069 | short expected_result; |
| 5070 | short result; |
| 5071 | |
| 5072 | |
| 5073 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 5074 | |
| 5075 | expected_result = (short) (source1_s & source2_ul); |
| 5076 | |
| 5077 | result = proc(source1_s, source2_ul); |
| 5078 | if (expected_result != result) { |
| 5079 | printf("Failed short & unsigned long test, expected %d, got %d, for %d & %lu\n", |
| 5080 | expected_result, result, source1_s, source2_ul); |
| 5081 | if (dumped == 0) cod_dump(gen_code); |
| 5082 | failed++; |
| 5083 | dumped++; |
| 5084 | } |
| 5085 | } |
| 5086 | } |
| 5087 | if (verbose) printf(" done\n"); |
| 5088 | cod_free_parse_context(context); |
| 5089 | cod_code_free(gen_code); |
| 5090 | } |
| 5091 | if ((only_run_test == NULL((void*)0)) || |
| 5092 | (strcmp(only_run_test, "s&l") == 0)) { |
| 5093 | int i, j; |
| 5094 | static char code[] = "{\n\ |
| 5095 | short a = p1;\n\ |
| 5096 | long b = p2;\n\ |
| 5097 | return a & b;\n\ |
| 5098 | }"; |
| 5099 | |
| 5100 | short (*proc)(short a, long b); |
| 5101 | cod_parse_context context = new_cod_parse_context(); |
| 5102 | int dumped = 0; |
| 5103 | |
| 5104 | cod_code gen_code; |
| 5105 | |
| 5106 | /* test for short & long */ |
| 5107 | if (verbose) printf("test for short & long"); |
| 5108 | |
| 5109 | cod_assoc_externs(context, externs); |
| 5110 | cod_parse_for_context(extern_string, context); |
| 5111 | |
| 5112 | cod_subroutine_declaration("short proc(short p1, long p2)", |
| 5113 | context); |
| 5114 | gen_code = cod_code_gen(code, context); |
| 5115 | proc = (short (*)(short, long))(long)gen_code->func; |
| 5116 | |
| 5117 | |
| 5118 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 5119 | short source1_s = src1s_vals[i]; |
| 5120 | for (j=0 ; j < sizeof(src2l_vals)/sizeof(src2l_vals[0]) ; j++) { |
| 5121 | long source2_l = src2l_vals[j]; |
| 5122 | |
| 5123 | short expected_result; |
| 5124 | short result; |
| 5125 | |
| 5126 | |
| 5127 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 5128 | |
| 5129 | expected_result = (short) (source1_s & source2_l); |
| 5130 | |
| 5131 | result = proc(source1_s, source2_l); |
| 5132 | if (expected_result != result) { |
| 5133 | printf("Failed short & long test, expected %d, got %d, for %d & %ld\n", |
| 5134 | expected_result, result, source1_s, source2_l); |
| 5135 | if (dumped == 0) cod_dump(gen_code); |
| 5136 | failed++; |
| 5137 | dumped++; |
| 5138 | } |
| 5139 | } |
| 5140 | } |
| 5141 | if (verbose) printf(" done\n"); |
| 5142 | cod_free_parse_context(context); |
| 5143 | cod_code_free(gen_code); |
| 5144 | } |
| 5145 | } |
| 5146 | void and_us_tests() |
| 5147 | { |
| 5148 | if ((only_run_test == NULL((void*)0)) || |
| 5149 | (strcmp(only_run_test, "us&c") == 0)) { |
| 5150 | int i, j; |
| 5151 | static char code[] = "{\n\ |
| 5152 | unsigned short a = p1;\n\ |
| 5153 | signed char b = p2;\n\ |
| 5154 | return a & b;\n\ |
| 5155 | }"; |
| 5156 | |
| 5157 | unsigned short (*proc)(unsigned short a, signed char b); |
| 5158 | cod_parse_context context = new_cod_parse_context(); |
| 5159 | int dumped = 0; |
| 5160 | |
| 5161 | cod_code gen_code; |
| 5162 | |
| 5163 | /* test for unsigned short & signed char */ |
| 5164 | if (verbose) printf("test for unsigned short & signed char"); |
| 5165 | |
| 5166 | cod_assoc_externs(context, externs); |
| 5167 | cod_parse_for_context(extern_string, context); |
| 5168 | |
| 5169 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, signed char p2)", |
| 5170 | context); |
| 5171 | gen_code = cod_code_gen(code, context); |
| 5172 | proc = (unsigned short (*)(unsigned short, signed char))(long)gen_code->func; |
| 5173 | |
| 5174 | |
| 5175 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 5176 | unsigned short source1_us = src1us_vals[i]; |
| 5177 | for (j=0 ; j < sizeof(src2c_vals)/sizeof(src2c_vals[0]) ; j++) { |
| 5178 | signed char source2_c = src2c_vals[j]; |
| 5179 | |
| 5180 | unsigned short expected_result; |
| 5181 | unsigned short result; |
| 5182 | |
| 5183 | |
| 5184 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 5185 | |
| 5186 | expected_result = (unsigned short) (source1_us & source2_c); |
| 5187 | |
| 5188 | result = proc(source1_us, source2_c); |
| 5189 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 5190 | if (expected_result != result) { |
| 5191 | printf("Failed unsigned short & signed char test, expected %u, got %u, for %u & %d\n", |
| 5192 | expected_result, result, source1_us, source2_c); |
| 5193 | if (dumped == 0) cod_dump(gen_code); |
| 5194 | failed++; |
| 5195 | dumped++; |
| 5196 | } |
| 5197 | } |
| 5198 | } |
| 5199 | if (verbose) printf(" done\n"); |
| 5200 | cod_free_parse_context(context); |
| 5201 | cod_code_free(gen_code); |
| 5202 | } |
| 5203 | if ((only_run_test == NULL((void*)0)) || |
| 5204 | (strcmp(only_run_test, "us&uc") == 0)) { |
| 5205 | int i, j; |
| 5206 | static char code[] = "{\n\ |
| 5207 | unsigned short a = p1;\n\ |
| 5208 | unsigned char b = p2;\n\ |
| 5209 | return a & b;\n\ |
| 5210 | }"; |
| 5211 | |
| 5212 | unsigned short (*proc)(unsigned short a, unsigned char b); |
| 5213 | cod_parse_context context = new_cod_parse_context(); |
| 5214 | int dumped = 0; |
| 5215 | |
| 5216 | cod_code gen_code; |
| 5217 | |
| 5218 | /* test for unsigned short & unsigned char */ |
| 5219 | if (verbose) printf("test for unsigned short & unsigned char"); |
| 5220 | |
| 5221 | cod_assoc_externs(context, externs); |
| 5222 | cod_parse_for_context(extern_string, context); |
| 5223 | |
| 5224 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, unsigned char p2)", |
| 5225 | context); |
| 5226 | gen_code = cod_code_gen(code, context); |
| 5227 | proc = (unsigned short (*)(unsigned short, unsigned char))(long)gen_code->func; |
| 5228 | |
| 5229 | |
| 5230 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 5231 | unsigned short source1_us = src1us_vals[i]; |
| 5232 | for (j=0 ; j < sizeof(src2uc_vals)/sizeof(src2uc_vals[0]) ; j++) { |
| 5233 | unsigned char source2_uc = src2uc_vals[j]; |
| 5234 | |
| 5235 | unsigned short expected_result; |
| 5236 | unsigned short result; |
| 5237 | |
| 5238 | |
| 5239 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 5240 | |
| 5241 | expected_result = (unsigned short) (source1_us & source2_uc); |
| 5242 | |
| 5243 | result = proc(source1_us, source2_uc); |
| 5244 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 5245 | if (expected_result != result) { |
| 5246 | printf("Failed unsigned short & unsigned char test, expected %u, got %u, for %u & %u\n", |
| 5247 | expected_result, result, source1_us, source2_uc); |
| 5248 | if (dumped == 0) cod_dump(gen_code); |
| 5249 | failed++; |
| 5250 | dumped++; |
| 5251 | } |
| 5252 | } |
| 5253 | } |
| 5254 | if (verbose) printf(" done\n"); |
| 5255 | cod_free_parse_context(context); |
| 5256 | cod_code_free(gen_code); |
| 5257 | } |
| 5258 | if ((only_run_test == NULL((void*)0)) || |
| 5259 | (strcmp(only_run_test, "us&s") == 0)) { |
| 5260 | int i, j; |
| 5261 | static char code[] = "{\n\ |
| 5262 | unsigned short a = p1;\n\ |
| 5263 | short b = p2;\n\ |
| 5264 | return a & b;\n\ |
| 5265 | }"; |
| 5266 | |
| 5267 | unsigned short (*proc)(unsigned short a, short b); |
| 5268 | cod_parse_context context = new_cod_parse_context(); |
| 5269 | int dumped = 0; |
| 5270 | |
| 5271 | cod_code gen_code; |
| 5272 | |
| 5273 | /* test for unsigned short & short */ |
| 5274 | if (verbose) printf("test for unsigned short & short"); |
| 5275 | |
| 5276 | cod_assoc_externs(context, externs); |
| 5277 | cod_parse_for_context(extern_string, context); |
| 5278 | |
| 5279 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, short p2)", |
| 5280 | context); |
| 5281 | gen_code = cod_code_gen(code, context); |
| 5282 | proc = (unsigned short (*)(unsigned short, short))(long)gen_code->func; |
| 5283 | |
| 5284 | |
| 5285 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 5286 | unsigned short source1_us = src1us_vals[i]; |
| 5287 | for (j=0 ; j < sizeof(src2s_vals)/sizeof(src2s_vals[0]) ; j++) { |
| 5288 | short source2_s = src2s_vals[j]; |
| 5289 | |
| 5290 | unsigned short expected_result; |
| 5291 | unsigned short result; |
| 5292 | |
| 5293 | |
| 5294 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 5295 | |
| 5296 | expected_result = (unsigned short) (source1_us & source2_s); |
| 5297 | |
| 5298 | result = proc(source1_us, source2_s); |
| 5299 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 5300 | if (expected_result != result) { |
| 5301 | printf("Failed unsigned short & short test, expected %u, got %u, for %u & %d\n", |
| 5302 | expected_result, result, source1_us, source2_s); |
| 5303 | if (dumped == 0) cod_dump(gen_code); |
| 5304 | failed++; |
| 5305 | dumped++; |
| 5306 | } |
| 5307 | } |
| 5308 | } |
| 5309 | if (verbose) printf(" done\n"); |
| 5310 | cod_free_parse_context(context); |
| 5311 | cod_code_free(gen_code); |
| 5312 | } |
| 5313 | if ((only_run_test == NULL((void*)0)) || |
| 5314 | (strcmp(only_run_test, "us&us") == 0)) { |
| 5315 | int i, j; |
| 5316 | static char code[] = "{\n\ |
| 5317 | unsigned short a = p1;\n\ |
| 5318 | unsigned short b = p2;\n\ |
| 5319 | return a & b;\n\ |
| 5320 | }"; |
| 5321 | |
| 5322 | unsigned short (*proc)(unsigned short a, unsigned short b); |
| 5323 | cod_parse_context context = new_cod_parse_context(); |
| 5324 | int dumped = 0; |
| 5325 | |
| 5326 | cod_code gen_code; |
| 5327 | |
| 5328 | /* test for unsigned short & unsigned short */ |
| 5329 | if (verbose) printf("test for unsigned short & unsigned short"); |
| 5330 | |
| 5331 | cod_assoc_externs(context, externs); |
| 5332 | cod_parse_for_context(extern_string, context); |
| 5333 | |
| 5334 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, unsigned short p2)", |
| 5335 | context); |
| 5336 | gen_code = cod_code_gen(code, context); |
| 5337 | proc = (unsigned short (*)(unsigned short, unsigned short))(long)gen_code->func; |
| 5338 | |
| 5339 | |
| 5340 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 5341 | unsigned short source1_us = src1us_vals[i]; |
| 5342 | for (j=0 ; j < sizeof(src2us_vals)/sizeof(src2us_vals[0]) ; j++) { |
| 5343 | unsigned short source2_us = src2us_vals[j]; |
| 5344 | |
| 5345 | unsigned short expected_result; |
| 5346 | unsigned short result; |
| 5347 | |
| 5348 | |
| 5349 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 5350 | |
| 5351 | expected_result = (unsigned short) (source1_us & source2_us); |
| 5352 | |
| 5353 | result = proc(source1_us, source2_us); |
| 5354 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 5355 | if (expected_result != result) { |
| 5356 | printf("Failed unsigned short & unsigned short test, expected %u, got %u, for %u & %u\n", |
| 5357 | expected_result, result, source1_us, source2_us); |
| 5358 | if (dumped == 0) cod_dump(gen_code); |
| 5359 | failed++; |
| 5360 | dumped++; |
| 5361 | } |
| 5362 | } |
| 5363 | } |
| 5364 | if (verbose) printf(" done\n"); |
| 5365 | cod_free_parse_context(context); |
| 5366 | cod_code_free(gen_code); |
| 5367 | } |
| 5368 | if ((only_run_test == NULL((void*)0)) || |
| 5369 | (strcmp(only_run_test, "us&i") == 0)) { |
| 5370 | int i, j; |
| 5371 | static char code[] = "{\n\ |
| 5372 | unsigned short a = p1;\n\ |
| 5373 | int b = p2;\n\ |
| 5374 | return a & b;\n\ |
| 5375 | }"; |
| 5376 | |
| 5377 | unsigned short (*proc)(unsigned short a, int b); |
| 5378 | cod_parse_context context = new_cod_parse_context(); |
| 5379 | int dumped = 0; |
| 5380 | |
| 5381 | cod_code gen_code; |
| 5382 | |
| 5383 | /* test for unsigned short & int */ |
| 5384 | if (verbose) printf("test for unsigned short & int"); |
| 5385 | |
| 5386 | cod_assoc_externs(context, externs); |
| 5387 | cod_parse_for_context(extern_string, context); |
| 5388 | |
| 5389 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, int p2)", |
| 5390 | context); |
| 5391 | gen_code = cod_code_gen(code, context); |
| 5392 | proc = (unsigned short (*)(unsigned short, int))(long)gen_code->func; |
| 5393 | |
| 5394 | |
| 5395 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 5396 | unsigned short source1_us = src1us_vals[i]; |
| 5397 | for (j=0 ; j < sizeof(src2i_vals)/sizeof(src2i_vals[0]) ; j++) { |
| 5398 | int source2_i = src2i_vals[j]; |
| 5399 | |
| 5400 | unsigned short expected_result; |
| 5401 | unsigned short result; |
| 5402 | |
| 5403 | |
| 5404 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 5405 | |
| 5406 | expected_result = (unsigned short) (source1_us & source2_i); |
| 5407 | |
| 5408 | result = proc(source1_us, source2_i); |
| 5409 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 5410 | if (expected_result != result) { |
| 5411 | printf("Failed unsigned short & int test, expected %u, got %u, for %u & %d\n", |
| 5412 | expected_result, result, source1_us, source2_i); |
| 5413 | if (dumped == 0) cod_dump(gen_code); |
| 5414 | failed++; |
| 5415 | dumped++; |
| 5416 | } |
| 5417 | } |
| 5418 | } |
| 5419 | if (verbose) printf(" done\n"); |
| 5420 | cod_free_parse_context(context); |
| 5421 | cod_code_free(gen_code); |
| 5422 | } |
| 5423 | if ((only_run_test == NULL((void*)0)) || |
| 5424 | (strcmp(only_run_test, "us&u") == 0)) { |
| 5425 | int i, j; |
| 5426 | static char code[] = "{\n\ |
| 5427 | unsigned short a = p1;\n\ |
| 5428 | unsigned int b = p2;\n\ |
| 5429 | return a & b;\n\ |
| 5430 | }"; |
| 5431 | |
| 5432 | unsigned short (*proc)(unsigned short a, unsigned int b); |
| 5433 | cod_parse_context context = new_cod_parse_context(); |
| 5434 | int dumped = 0; |
| 5435 | |
| 5436 | cod_code gen_code; |
| 5437 | |
| 5438 | /* test for unsigned short & unsigned int */ |
| 5439 | if (verbose) printf("test for unsigned short & unsigned int"); |
| 5440 | |
| 5441 | cod_assoc_externs(context, externs); |
| 5442 | cod_parse_for_context(extern_string, context); |
| 5443 | |
| 5444 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, unsigned int p2)", |
| 5445 | context); |
| 5446 | gen_code = cod_code_gen(code, context); |
| 5447 | proc = (unsigned short (*)(unsigned short, unsigned int))(long)gen_code->func; |
| 5448 | |
| 5449 | |
| 5450 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 5451 | unsigned short source1_us = src1us_vals[i]; |
| 5452 | for (j=0 ; j < sizeof(src2u_vals)/sizeof(src2u_vals[0]) ; j++) { |
| 5453 | unsigned int source2_u = src2u_vals[j]; |
| 5454 | |
| 5455 | unsigned short expected_result; |
| 5456 | unsigned short result; |
| 5457 | |
| 5458 | |
| 5459 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 5460 | |
| 5461 | expected_result = (unsigned short) (source1_us & source2_u); |
| 5462 | |
| 5463 | result = proc(source1_us, source2_u); |
| 5464 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 5465 | if (expected_result != result) { |
| 5466 | printf("Failed unsigned short & unsigned int test, expected %u, got %u, for %u & %u\n", |
| 5467 | expected_result, result, source1_us, source2_u); |
| 5468 | if (dumped == 0) cod_dump(gen_code); |
| 5469 | failed++; |
| 5470 | dumped++; |
| 5471 | } |
| 5472 | } |
| 5473 | } |
| 5474 | if (verbose) printf(" done\n"); |
| 5475 | cod_free_parse_context(context); |
| 5476 | cod_code_free(gen_code); |
| 5477 | } |
| 5478 | if ((only_run_test == NULL((void*)0)) || |
| 5479 | (strcmp(only_run_test, "us&ul") == 0)) { |
| 5480 | int i, j; |
| 5481 | static char code[] = "{\n\ |
| 5482 | unsigned short a = p1;\n\ |
| 5483 | unsigned long b = p2;\n\ |
| 5484 | return a & b;\n\ |
| 5485 | }"; |
| 5486 | |
| 5487 | unsigned short (*proc)(unsigned short a, unsigned long b); |
| 5488 | cod_parse_context context = new_cod_parse_context(); |
| 5489 | int dumped = 0; |
| 5490 | |
| 5491 | cod_code gen_code; |
| 5492 | |
| 5493 | /* test for unsigned short & unsigned long */ |
| 5494 | if (verbose) printf("test for unsigned short & unsigned long"); |
| 5495 | |
| 5496 | cod_assoc_externs(context, externs); |
| 5497 | cod_parse_for_context(extern_string, context); |
| 5498 | |
| 5499 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, unsigned long p2)", |
| 5500 | context); |
| 5501 | gen_code = cod_code_gen(code, context); |
| 5502 | proc = (unsigned short (*)(unsigned short, unsigned long))(long)gen_code->func; |
| 5503 | |
| 5504 | |
| 5505 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 5506 | unsigned short source1_us = src1us_vals[i]; |
| 5507 | for (j=0 ; j < sizeof(src2ul_vals)/sizeof(src2ul_vals[0]) ; j++) { |
| 5508 | unsigned long source2_ul = src2ul_vals[j]; |
| 5509 | |
| 5510 | unsigned short expected_result; |
| 5511 | unsigned short result; |
| 5512 | |
| 5513 | |
| 5514 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 5515 | |
| 5516 | expected_result = (unsigned short) (source1_us & source2_ul); |
| 5517 | |
| 5518 | result = proc(source1_us, source2_ul); |
| 5519 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 5520 | if (expected_result != result) { |
| 5521 | printf("Failed unsigned short & unsigned long test, expected %u, got %u, for %u & %lu\n", |
| 5522 | expected_result, result, source1_us, source2_ul); |
| 5523 | if (dumped == 0) cod_dump(gen_code); |
| 5524 | failed++; |
| 5525 | dumped++; |
| 5526 | } |
| 5527 | } |
| 5528 | } |
| 5529 | if (verbose) printf(" done\n"); |
| 5530 | cod_free_parse_context(context); |
| 5531 | cod_code_free(gen_code); |
| 5532 | } |
| 5533 | if ((only_run_test == NULL((void*)0)) || |
| 5534 | (strcmp(only_run_test, "us&l") == 0)) { |
| 5535 | int i, j; |
| 5536 | static char code[] = "{\n\ |
| 5537 | unsigned short a = p1;\n\ |
| 5538 | long b = p2;\n\ |
| 5539 | return a & b;\n\ |
| 5540 | }"; |
| 5541 | |
| 5542 | unsigned short (*proc)(unsigned short a, long b); |
| 5543 | cod_parse_context context = new_cod_parse_context(); |
| 5544 | int dumped = 0; |
| 5545 | |
| 5546 | cod_code gen_code; |
| 5547 | |
| 5548 | /* test for unsigned short & long */ |
| 5549 | if (verbose) printf("test for unsigned short & long"); |
| 5550 | |
| 5551 | cod_assoc_externs(context, externs); |
| 5552 | cod_parse_for_context(extern_string, context); |
| 5553 | |
| 5554 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, long p2)", |
| 5555 | context); |
| 5556 | gen_code = cod_code_gen(code, context); |
| 5557 | proc = (unsigned short (*)(unsigned short, long))(long)gen_code->func; |
| 5558 | |
| 5559 | |
| 5560 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 5561 | unsigned short source1_us = src1us_vals[i]; |
| 5562 | for (j=0 ; j < sizeof(src2l_vals)/sizeof(src2l_vals[0]) ; j++) { |
| 5563 | long source2_l = src2l_vals[j]; |
| 5564 | |
| 5565 | unsigned short expected_result; |
| 5566 | unsigned short result; |
| 5567 | |
| 5568 | |
| 5569 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 5570 | |
| 5571 | expected_result = (unsigned short) (source1_us & source2_l); |
| 5572 | |
| 5573 | result = proc(source1_us, source2_l); |
| 5574 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 5575 | if (expected_result != result) { |
| 5576 | printf("Failed unsigned short & long test, expected %u, got %u, for %u & %ld\n", |
| 5577 | expected_result, result, source1_us, source2_l); |
| 5578 | if (dumped == 0) cod_dump(gen_code); |
| 5579 | failed++; |
| 5580 | dumped++; |
| 5581 | } |
| 5582 | } |
| 5583 | } |
| 5584 | if (verbose) printf(" done\n"); |
| 5585 | cod_free_parse_context(context); |
| 5586 | cod_code_free(gen_code); |
| 5587 | } |
| 5588 | } |
| 5589 | void and_i_tests() |
| 5590 | { |
| 5591 | if ((only_run_test == NULL((void*)0)) || |
| 5592 | (strcmp(only_run_test, "i&c") == 0)) { |
| 5593 | int i, j; |
| 5594 | static char code[] = "{\n\ |
| 5595 | int a = p1;\n\ |
| 5596 | signed char b = p2;\n\ |
| 5597 | return a & b;\n\ |
| 5598 | }"; |
| 5599 | |
| 5600 | int (*proc)(int a, signed char b); |
| 5601 | cod_parse_context context = new_cod_parse_context(); |
| 5602 | int dumped = 0; |
| 5603 | |
| 5604 | cod_code gen_code; |
| 5605 | |
| 5606 | /* test for int & signed char */ |
| 5607 | if (verbose) printf("test for int & signed char"); |
| 5608 | |
| 5609 | cod_assoc_externs(context, externs); |
| 5610 | cod_parse_for_context(extern_string, context); |
| 5611 | |
| 5612 | cod_subroutine_declaration("int proc(int p1, signed char p2)", |
| 5613 | context); |
| 5614 | gen_code = cod_code_gen(code, context); |
| 5615 | proc = (int (*)(int, signed char))(long)gen_code->func; |
| 5616 | |
| 5617 | |
| 5618 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 5619 | int source1_i = src1i_vals[i]; |
| 5620 | for (j=0 ; j < sizeof(src2c_vals)/sizeof(src2c_vals[0]) ; j++) { |
| 5621 | signed char source2_c = src2c_vals[j]; |
| 5622 | |
| 5623 | int expected_result; |
| 5624 | int result; |
| 5625 | |
| 5626 | |
| 5627 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 5628 | |
| 5629 | expected_result = (int) (source1_i & source2_c); |
| 5630 | |
| 5631 | result = proc(source1_i, source2_c); |
| 5632 | if (expected_result != result) { |
| 5633 | printf("Failed int & signed char test, expected %d, got %d, for %d & %d\n", |
| 5634 | expected_result, result, source1_i, source2_c); |
| 5635 | if (dumped == 0) cod_dump(gen_code); |
| 5636 | failed++; |
| 5637 | dumped++; |
| 5638 | } |
| 5639 | } |
| 5640 | } |
| 5641 | if (verbose) printf(" done\n"); |
| 5642 | cod_free_parse_context(context); |
| 5643 | cod_code_free(gen_code); |
| 5644 | } |
| 5645 | if ((only_run_test == NULL((void*)0)) || |
| 5646 | (strcmp(only_run_test, "i&uc") == 0)) { |
| 5647 | int i, j; |
| 5648 | static char code[] = "{\n\ |
| 5649 | int a = p1;\n\ |
| 5650 | unsigned char b = p2;\n\ |
| 5651 | return a & b;\n\ |
| 5652 | }"; |
| 5653 | |
| 5654 | int (*proc)(int a, unsigned char b); |
| 5655 | cod_parse_context context = new_cod_parse_context(); |
| 5656 | int dumped = 0; |
| 5657 | |
| 5658 | cod_code gen_code; |
| 5659 | |
| 5660 | /* test for int & unsigned char */ |
| 5661 | if (verbose) printf("test for int & unsigned char"); |
| 5662 | |
| 5663 | cod_assoc_externs(context, externs); |
| 5664 | cod_parse_for_context(extern_string, context); |
| 5665 | |
| 5666 | cod_subroutine_declaration("int proc(int p1, unsigned char p2)", |
| 5667 | context); |
| 5668 | gen_code = cod_code_gen(code, context); |
| 5669 | proc = (int (*)(int, unsigned char))(long)gen_code->func; |
| 5670 | |
| 5671 | |
| 5672 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 5673 | int source1_i = src1i_vals[i]; |
| 5674 | for (j=0 ; j < sizeof(src2uc_vals)/sizeof(src2uc_vals[0]) ; j++) { |
| 5675 | unsigned char source2_uc = src2uc_vals[j]; |
| 5676 | |
| 5677 | int expected_result; |
| 5678 | int result; |
| 5679 | |
| 5680 | |
| 5681 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 5682 | |
| 5683 | expected_result = (int) (source1_i & source2_uc); |
| 5684 | |
| 5685 | result = proc(source1_i, source2_uc); |
| 5686 | if (expected_result != result) { |
| 5687 | printf("Failed int & unsigned char test, expected %d, got %d, for %d & %u\n", |
| 5688 | expected_result, result, source1_i, source2_uc); |
| 5689 | if (dumped == 0) cod_dump(gen_code); |
| 5690 | failed++; |
| 5691 | dumped++; |
| 5692 | } |
| 5693 | } |
| 5694 | } |
| 5695 | if (verbose) printf(" done\n"); |
| 5696 | cod_free_parse_context(context); |
| 5697 | cod_code_free(gen_code); |
| 5698 | } |
| 5699 | if ((only_run_test == NULL((void*)0)) || |
| 5700 | (strcmp(only_run_test, "i&s") == 0)) { |
| 5701 | int i, j; |
| 5702 | static char code[] = "{\n\ |
| 5703 | int a = p1;\n\ |
| 5704 | short b = p2;\n\ |
| 5705 | return a & b;\n\ |
| 5706 | }"; |
| 5707 | |
| 5708 | int (*proc)(int a, short b); |
| 5709 | cod_parse_context context = new_cod_parse_context(); |
| 5710 | int dumped = 0; |
| 5711 | |
| 5712 | cod_code gen_code; |
| 5713 | |
| 5714 | /* test for int & short */ |
| 5715 | if (verbose) printf("test for int & short"); |
| 5716 | |
| 5717 | cod_assoc_externs(context, externs); |
| 5718 | cod_parse_for_context(extern_string, context); |
| 5719 | |
| 5720 | cod_subroutine_declaration("int proc(int p1, short p2)", |
| 5721 | context); |
| 5722 | gen_code = cod_code_gen(code, context); |
| 5723 | proc = (int (*)(int, short))(long)gen_code->func; |
| 5724 | |
| 5725 | |
| 5726 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 5727 | int source1_i = src1i_vals[i]; |
| 5728 | for (j=0 ; j < sizeof(src2s_vals)/sizeof(src2s_vals[0]) ; j++) { |
| 5729 | short source2_s = src2s_vals[j]; |
| 5730 | |
| 5731 | int expected_result; |
| 5732 | int result; |
| 5733 | |
| 5734 | |
| 5735 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 5736 | |
| 5737 | expected_result = (int) (source1_i & source2_s); |
| 5738 | |
| 5739 | result = proc(source1_i, source2_s); |
| 5740 | if (expected_result != result) { |
| 5741 | printf("Failed int & short test, expected %d, got %d, for %d & %d\n", |
| 5742 | expected_result, result, source1_i, source2_s); |
| 5743 | if (dumped == 0) cod_dump(gen_code); |
| 5744 | failed++; |
| 5745 | dumped++; |
| 5746 | } |
| 5747 | } |
| 5748 | } |
| 5749 | if (verbose) printf(" done\n"); |
| 5750 | cod_free_parse_context(context); |
| 5751 | cod_code_free(gen_code); |
| 5752 | } |
| 5753 | if ((only_run_test == NULL((void*)0)) || |
| 5754 | (strcmp(only_run_test, "i&us") == 0)) { |
| 5755 | int i, j; |
| 5756 | static char code[] = "{\n\ |
| 5757 | int a = p1;\n\ |
| 5758 | unsigned short b = p2;\n\ |
| 5759 | return a & b;\n\ |
| 5760 | }"; |
| 5761 | |
| 5762 | int (*proc)(int a, unsigned short b); |
| 5763 | cod_parse_context context = new_cod_parse_context(); |
| 5764 | int dumped = 0; |
| 5765 | |
| 5766 | cod_code gen_code; |
| 5767 | |
| 5768 | /* test for int & unsigned short */ |
| 5769 | if (verbose) printf("test for int & unsigned short"); |
| 5770 | |
| 5771 | cod_assoc_externs(context, externs); |
| 5772 | cod_parse_for_context(extern_string, context); |
| 5773 | |
| 5774 | cod_subroutine_declaration("int proc(int p1, unsigned short p2)", |
| 5775 | context); |
| 5776 | gen_code = cod_code_gen(code, context); |
| 5777 | proc = (int (*)(int, unsigned short))(long)gen_code->func; |
| 5778 | |
| 5779 | |
| 5780 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 5781 | int source1_i = src1i_vals[i]; |
| 5782 | for (j=0 ; j < sizeof(src2us_vals)/sizeof(src2us_vals[0]) ; j++) { |
| 5783 | unsigned short source2_us = src2us_vals[j]; |
| 5784 | |
| 5785 | int expected_result; |
| 5786 | int result; |
| 5787 | |
| 5788 | |
| 5789 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 5790 | |
| 5791 | expected_result = (int) (source1_i & source2_us); |
| 5792 | |
| 5793 | result = proc(source1_i, source2_us); |
| 5794 | if (expected_result != result) { |
| 5795 | printf("Failed int & unsigned short test, expected %d, got %d, for %d & %u\n", |
| 5796 | expected_result, result, source1_i, source2_us); |
| 5797 | if (dumped == 0) cod_dump(gen_code); |
| 5798 | failed++; |
| 5799 | dumped++; |
| 5800 | } |
| 5801 | } |
| 5802 | } |
| 5803 | if (verbose) printf(" done\n"); |
| 5804 | cod_free_parse_context(context); |
| 5805 | cod_code_free(gen_code); |
| 5806 | } |
| 5807 | if ((only_run_test == NULL((void*)0)) || |
| 5808 | (strcmp(only_run_test, "i&i") == 0)) { |
| 5809 | int i, j; |
| 5810 | static char code[] = "{\n\ |
| 5811 | int a = p1;\n\ |
| 5812 | int b = p2;\n\ |
| 5813 | return a & b;\n\ |
| 5814 | }"; |
| 5815 | |
| 5816 | int (*proc)(int a, int b); |
| 5817 | cod_parse_context context = new_cod_parse_context(); |
| 5818 | int dumped = 0; |
| 5819 | |
| 5820 | cod_code gen_code; |
| 5821 | |
| 5822 | /* test for int & int */ |
| 5823 | if (verbose) printf("test for int & int"); |
| 5824 | |
| 5825 | cod_assoc_externs(context, externs); |
| 5826 | cod_parse_for_context(extern_string, context); |
| 5827 | |
| 5828 | cod_subroutine_declaration("int proc(int p1, int p2)", |
| 5829 | context); |
| 5830 | gen_code = cod_code_gen(code, context); |
| 5831 | proc = (int (*)(int, int))(long)gen_code->func; |
| 5832 | |
| 5833 | |
| 5834 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 5835 | int source1_i = src1i_vals[i]; |
| 5836 | for (j=0 ; j < sizeof(src2i_vals)/sizeof(src2i_vals[0]) ; j++) { |
| 5837 | int source2_i = src2i_vals[j]; |
| 5838 | |
| 5839 | int expected_result; |
| 5840 | int result; |
| 5841 | |
| 5842 | |
| 5843 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 5844 | |
| 5845 | expected_result = (int) (source1_i & source2_i); |
| 5846 | |
| 5847 | result = proc(source1_i, source2_i); |
| 5848 | if (expected_result != result) { |
| 5849 | printf("Failed int & int test, expected %d, got %d, for %d & %d\n", |
| 5850 | expected_result, result, source1_i, source2_i); |
| 5851 | if (dumped == 0) cod_dump(gen_code); |
| 5852 | failed++; |
| 5853 | dumped++; |
| 5854 | } |
| 5855 | } |
| 5856 | } |
| 5857 | if (verbose) printf(" done\n"); |
| 5858 | cod_free_parse_context(context); |
| 5859 | cod_code_free(gen_code); |
| 5860 | } |
| 5861 | if ((only_run_test == NULL((void*)0)) || |
| 5862 | (strcmp(only_run_test, "i&u") == 0)) { |
| 5863 | int i, j; |
| 5864 | static char code[] = "{\n\ |
| 5865 | int a = p1;\n\ |
| 5866 | unsigned int b = p2;\n\ |
| 5867 | return a & b;\n\ |
| 5868 | }"; |
| 5869 | |
| 5870 | int (*proc)(int a, unsigned int b); |
| 5871 | cod_parse_context context = new_cod_parse_context(); |
| 5872 | int dumped = 0; |
| 5873 | |
| 5874 | cod_code gen_code; |
| 5875 | |
| 5876 | /* test for int & unsigned int */ |
| 5877 | if (verbose) printf("test for int & unsigned int"); |
| 5878 | |
| 5879 | cod_assoc_externs(context, externs); |
| 5880 | cod_parse_for_context(extern_string, context); |
| 5881 | |
| 5882 | cod_subroutine_declaration("int proc(int p1, unsigned int p2)", |
| 5883 | context); |
| 5884 | gen_code = cod_code_gen(code, context); |
| 5885 | proc = (int (*)(int, unsigned int))(long)gen_code->func; |
| 5886 | |
| 5887 | |
| 5888 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 5889 | int source1_i = src1i_vals[i]; |
| 5890 | for (j=0 ; j < sizeof(src2u_vals)/sizeof(src2u_vals[0]) ; j++) { |
| 5891 | unsigned int source2_u = src2u_vals[j]; |
| 5892 | |
| 5893 | int expected_result; |
| 5894 | int result; |
| 5895 | |
| 5896 | |
| 5897 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 5898 | |
| 5899 | expected_result = (int) (source1_i & source2_u); |
| 5900 | |
| 5901 | result = proc(source1_i, source2_u); |
| 5902 | if (expected_result != result) { |
| 5903 | printf("Failed int & unsigned int test, expected %d, got %d, for %d & %u\n", |
| 5904 | expected_result, result, source1_i, source2_u); |
| 5905 | if (dumped == 0) cod_dump(gen_code); |
| 5906 | failed++; |
| 5907 | dumped++; |
| 5908 | } |
| 5909 | } |
| 5910 | } |
| 5911 | if (verbose) printf(" done\n"); |
| 5912 | cod_free_parse_context(context); |
| 5913 | cod_code_free(gen_code); |
| 5914 | } |
| 5915 | if ((only_run_test == NULL((void*)0)) || |
| 5916 | (strcmp(only_run_test, "i&ul") == 0)) { |
| 5917 | int i, j; |
| 5918 | static char code[] = "{\n\ |
| 5919 | int a = p1;\n\ |
| 5920 | unsigned long b = p2;\n\ |
| 5921 | return a & b;\n\ |
| 5922 | }"; |
| 5923 | |
| 5924 | int (*proc)(int a, unsigned long b); |
| 5925 | cod_parse_context context = new_cod_parse_context(); |
| 5926 | int dumped = 0; |
| 5927 | |
| 5928 | cod_code gen_code; |
| 5929 | |
| 5930 | /* test for int & unsigned long */ |
| 5931 | if (verbose) printf("test for int & unsigned long"); |
| 5932 | |
| 5933 | cod_assoc_externs(context, externs); |
| 5934 | cod_parse_for_context(extern_string, context); |
| 5935 | |
| 5936 | cod_subroutine_declaration("int proc(int p1, unsigned long p2)", |
| 5937 | context); |
| 5938 | gen_code = cod_code_gen(code, context); |
| 5939 | proc = (int (*)(int, unsigned long))(long)gen_code->func; |
| 5940 | |
| 5941 | |
| 5942 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 5943 | int source1_i = src1i_vals[i]; |
| 5944 | for (j=0 ; j < sizeof(src2ul_vals)/sizeof(src2ul_vals[0]) ; j++) { |
| 5945 | unsigned long source2_ul = src2ul_vals[j]; |
| 5946 | |
| 5947 | int expected_result; |
| 5948 | int result; |
| 5949 | |
| 5950 | |
| 5951 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 5952 | |
| 5953 | expected_result = (int) (source1_i & source2_ul); |
| 5954 | |
| 5955 | result = proc(source1_i, source2_ul); |
| 5956 | if (expected_result != result) { |
| 5957 | printf("Failed int & unsigned long test, expected %d, got %d, for %d & %lu\n", |
| 5958 | expected_result, result, source1_i, source2_ul); |
| 5959 | if (dumped == 0) cod_dump(gen_code); |
| 5960 | failed++; |
| 5961 | dumped++; |
| 5962 | } |
| 5963 | } |
| 5964 | } |
| 5965 | if (verbose) printf(" done\n"); |
| 5966 | cod_free_parse_context(context); |
| 5967 | cod_code_free(gen_code); |
| 5968 | } |
| 5969 | if ((only_run_test == NULL((void*)0)) || |
| 5970 | (strcmp(only_run_test, "i&l") == 0)) { |
| 5971 | int i, j; |
| 5972 | static char code[] = "{\n\ |
| 5973 | int a = p1;\n\ |
| 5974 | long b = p2;\n\ |
| 5975 | return a & b;\n\ |
| 5976 | }"; |
| 5977 | |
| 5978 | int (*proc)(int a, long b); |
| 5979 | cod_parse_context context = new_cod_parse_context(); |
| 5980 | int dumped = 0; |
| 5981 | |
| 5982 | cod_code gen_code; |
| 5983 | |
| 5984 | /* test for int & long */ |
| 5985 | if (verbose) printf("test for int & long"); |
| 5986 | |
| 5987 | cod_assoc_externs(context, externs); |
| 5988 | cod_parse_for_context(extern_string, context); |
| 5989 | |
| 5990 | cod_subroutine_declaration("int proc(int p1, long p2)", |
| 5991 | context); |
| 5992 | gen_code = cod_code_gen(code, context); |
| 5993 | proc = (int (*)(int, long))(long)gen_code->func; |
| 5994 | |
| 5995 | |
| 5996 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 5997 | int source1_i = src1i_vals[i]; |
| 5998 | for (j=0 ; j < sizeof(src2l_vals)/sizeof(src2l_vals[0]) ; j++) { |
| 5999 | long source2_l = src2l_vals[j]; |
| 6000 | |
| 6001 | int expected_result; |
| 6002 | int result; |
| 6003 | |
| 6004 | |
| 6005 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 6006 | |
| 6007 | expected_result = (int) (source1_i & source2_l); |
| 6008 | |
| 6009 | result = proc(source1_i, source2_l); |
| 6010 | if (expected_result != result) { |
| 6011 | printf("Failed int & long test, expected %d, got %d, for %d & %ld\n", |
| 6012 | expected_result, result, source1_i, source2_l); |
| 6013 | if (dumped == 0) cod_dump(gen_code); |
| 6014 | failed++; |
| 6015 | dumped++; |
| 6016 | } |
| 6017 | } |
| 6018 | } |
| 6019 | if (verbose) printf(" done\n"); |
| 6020 | cod_free_parse_context(context); |
| 6021 | cod_code_free(gen_code); |
| 6022 | } |
| 6023 | } |
| 6024 | void and_u_tests() |
| 6025 | { |
| 6026 | if ((only_run_test == NULL((void*)0)) || |
| 6027 | (strcmp(only_run_test, "u&c") == 0)) { |
| 6028 | int i, j; |
| 6029 | static char code[] = "{\n\ |
| 6030 | unsigned int a = p1;\n\ |
| 6031 | signed char b = p2;\n\ |
| 6032 | return a & b;\n\ |
| 6033 | }"; |
| 6034 | |
| 6035 | unsigned int (*proc)(unsigned int a, signed char b); |
| 6036 | cod_parse_context context = new_cod_parse_context(); |
| 6037 | int dumped = 0; |
| 6038 | |
| 6039 | cod_code gen_code; |
| 6040 | |
| 6041 | /* test for unsigned int & signed char */ |
| 6042 | if (verbose) printf("test for unsigned int & signed char"); |
| 6043 | |
| 6044 | cod_assoc_externs(context, externs); |
| 6045 | cod_parse_for_context(extern_string, context); |
| 6046 | |
| 6047 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, signed char p2)", |
| 6048 | context); |
| 6049 | gen_code = cod_code_gen(code, context); |
| 6050 | proc = (unsigned int (*)(unsigned int, signed char))(long)gen_code->func; |
| 6051 | |
| 6052 | |
| 6053 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 6054 | unsigned int source1_u = src1u_vals[i]; |
| 6055 | for (j=0 ; j < sizeof(src2c_vals)/sizeof(src2c_vals[0]) ; j++) { |
| 6056 | signed char source2_c = src2c_vals[j]; |
| 6057 | |
| 6058 | unsigned int expected_result; |
| 6059 | unsigned int result; |
| 6060 | |
| 6061 | |
| 6062 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 6063 | |
| 6064 | expected_result = (unsigned int) (source1_u & source2_c); |
| 6065 | |
| 6066 | result = proc(source1_u, source2_c); |
| 6067 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 6068 | if (expected_result != result) { |
| 6069 | printf("Failed unsigned int & signed char test, expected %u, got %u, for %u & %d\n", |
| 6070 | expected_result, result, source1_u, source2_c); |
| 6071 | if (dumped == 0) cod_dump(gen_code); |
| 6072 | failed++; |
| 6073 | dumped++; |
| 6074 | } |
| 6075 | } |
| 6076 | } |
| 6077 | if (verbose) printf(" done\n"); |
| 6078 | cod_free_parse_context(context); |
| 6079 | cod_code_free(gen_code); |
| 6080 | } |
| 6081 | if ((only_run_test == NULL((void*)0)) || |
| 6082 | (strcmp(only_run_test, "u&uc") == 0)) { |
| 6083 | int i, j; |
| 6084 | static char code[] = "{\n\ |
| 6085 | unsigned int a = p1;\n\ |
| 6086 | unsigned char b = p2;\n\ |
| 6087 | return a & b;\n\ |
| 6088 | }"; |
| 6089 | |
| 6090 | unsigned int (*proc)(unsigned int a, unsigned char b); |
| 6091 | cod_parse_context context = new_cod_parse_context(); |
| 6092 | int dumped = 0; |
| 6093 | |
| 6094 | cod_code gen_code; |
| 6095 | |
| 6096 | /* test for unsigned int & unsigned char */ |
| 6097 | if (verbose) printf("test for unsigned int & unsigned char"); |
| 6098 | |
| 6099 | cod_assoc_externs(context, externs); |
| 6100 | cod_parse_for_context(extern_string, context); |
| 6101 | |
| 6102 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, unsigned char p2)", |
| 6103 | context); |
| 6104 | gen_code = cod_code_gen(code, context); |
| 6105 | proc = (unsigned int (*)(unsigned int, unsigned char))(long)gen_code->func; |
| 6106 | |
| 6107 | |
| 6108 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 6109 | unsigned int source1_u = src1u_vals[i]; |
| 6110 | for (j=0 ; j < sizeof(src2uc_vals)/sizeof(src2uc_vals[0]) ; j++) { |
| 6111 | unsigned char source2_uc = src2uc_vals[j]; |
| 6112 | |
| 6113 | unsigned int expected_result; |
| 6114 | unsigned int result; |
| 6115 | |
| 6116 | |
| 6117 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 6118 | |
| 6119 | expected_result = (unsigned int) (source1_u & source2_uc); |
| 6120 | |
| 6121 | result = proc(source1_u, source2_uc); |
| 6122 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 6123 | if (expected_result != result) { |
| 6124 | printf("Failed unsigned int & unsigned char test, expected %u, got %u, for %u & %u\n", |
| 6125 | expected_result, result, source1_u, source2_uc); |
| 6126 | if (dumped == 0) cod_dump(gen_code); |
| 6127 | failed++; |
| 6128 | dumped++; |
| 6129 | } |
| 6130 | } |
| 6131 | } |
| 6132 | if (verbose) printf(" done\n"); |
| 6133 | cod_free_parse_context(context); |
| 6134 | cod_code_free(gen_code); |
| 6135 | } |
| 6136 | if ((only_run_test == NULL((void*)0)) || |
| 6137 | (strcmp(only_run_test, "u&s") == 0)) { |
| 6138 | int i, j; |
| 6139 | static char code[] = "{\n\ |
| 6140 | unsigned int a = p1;\n\ |
| 6141 | short b = p2;\n\ |
| 6142 | return a & b;\n\ |
| 6143 | }"; |
| 6144 | |
| 6145 | unsigned int (*proc)(unsigned int a, short b); |
| 6146 | cod_parse_context context = new_cod_parse_context(); |
| 6147 | int dumped = 0; |
| 6148 | |
| 6149 | cod_code gen_code; |
| 6150 | |
| 6151 | /* test for unsigned int & short */ |
| 6152 | if (verbose) printf("test for unsigned int & short"); |
| 6153 | |
| 6154 | cod_assoc_externs(context, externs); |
| 6155 | cod_parse_for_context(extern_string, context); |
| 6156 | |
| 6157 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, short p2)", |
| 6158 | context); |
| 6159 | gen_code = cod_code_gen(code, context); |
| 6160 | proc = (unsigned int (*)(unsigned int, short))(long)gen_code->func; |
| 6161 | |
| 6162 | |
| 6163 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 6164 | unsigned int source1_u = src1u_vals[i]; |
| 6165 | for (j=0 ; j < sizeof(src2s_vals)/sizeof(src2s_vals[0]) ; j++) { |
| 6166 | short source2_s = src2s_vals[j]; |
| 6167 | |
| 6168 | unsigned int expected_result; |
| 6169 | unsigned int result; |
| 6170 | |
| 6171 | |
| 6172 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 6173 | |
| 6174 | expected_result = (unsigned int) (source1_u & source2_s); |
| 6175 | |
| 6176 | result = proc(source1_u, source2_s); |
| 6177 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 6178 | if (expected_result != result) { |
| 6179 | printf("Failed unsigned int & short test, expected %u, got %u, for %u & %d\n", |
| 6180 | expected_result, result, source1_u, source2_s); |
| 6181 | if (dumped == 0) cod_dump(gen_code); |
| 6182 | failed++; |
| 6183 | dumped++; |
| 6184 | } |
| 6185 | } |
| 6186 | } |
| 6187 | if (verbose) printf(" done\n"); |
| 6188 | cod_free_parse_context(context); |
| 6189 | cod_code_free(gen_code); |
| 6190 | } |
| 6191 | if ((only_run_test == NULL((void*)0)) || |
| 6192 | (strcmp(only_run_test, "u&us") == 0)) { |
| 6193 | int i, j; |
| 6194 | static char code[] = "{\n\ |
| 6195 | unsigned int a = p1;\n\ |
| 6196 | unsigned short b = p2;\n\ |
| 6197 | return a & b;\n\ |
| 6198 | }"; |
| 6199 | |
| 6200 | unsigned int (*proc)(unsigned int a, unsigned short b); |
| 6201 | cod_parse_context context = new_cod_parse_context(); |
| 6202 | int dumped = 0; |
| 6203 | |
| 6204 | cod_code gen_code; |
| 6205 | |
| 6206 | /* test for unsigned int & unsigned short */ |
| 6207 | if (verbose) printf("test for unsigned int & unsigned short"); |
| 6208 | |
| 6209 | cod_assoc_externs(context, externs); |
| 6210 | cod_parse_for_context(extern_string, context); |
| 6211 | |
| 6212 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, unsigned short p2)", |
| 6213 | context); |
| 6214 | gen_code = cod_code_gen(code, context); |
| 6215 | proc = (unsigned int (*)(unsigned int, unsigned short))(long)gen_code->func; |
| 6216 | |
| 6217 | |
| 6218 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 6219 | unsigned int source1_u = src1u_vals[i]; |
| 6220 | for (j=0 ; j < sizeof(src2us_vals)/sizeof(src2us_vals[0]) ; j++) { |
| 6221 | unsigned short source2_us = src2us_vals[j]; |
| 6222 | |
| 6223 | unsigned int expected_result; |
| 6224 | unsigned int result; |
| 6225 | |
| 6226 | |
| 6227 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 6228 | |
| 6229 | expected_result = (unsigned int) (source1_u & source2_us); |
| 6230 | |
| 6231 | result = proc(source1_u, source2_us); |
| 6232 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 6233 | if (expected_result != result) { |
| 6234 | printf("Failed unsigned int & unsigned short test, expected %u, got %u, for %u & %u\n", |
| 6235 | expected_result, result, source1_u, source2_us); |
| 6236 | if (dumped == 0) cod_dump(gen_code); |
| 6237 | failed++; |
| 6238 | dumped++; |
| 6239 | } |
| 6240 | } |
| 6241 | } |
| 6242 | if (verbose) printf(" done\n"); |
| 6243 | cod_free_parse_context(context); |
| 6244 | cod_code_free(gen_code); |
| 6245 | } |
| 6246 | if ((only_run_test == NULL((void*)0)) || |
| 6247 | (strcmp(only_run_test, "u&i") == 0)) { |
| 6248 | int i, j; |
| 6249 | static char code[] = "{\n\ |
| 6250 | unsigned int a = p1;\n\ |
| 6251 | int b = p2;\n\ |
| 6252 | return a & b;\n\ |
| 6253 | }"; |
| 6254 | |
| 6255 | unsigned int (*proc)(unsigned int a, int b); |
| 6256 | cod_parse_context context = new_cod_parse_context(); |
| 6257 | int dumped = 0; |
| 6258 | |
| 6259 | cod_code gen_code; |
| 6260 | |
| 6261 | /* test for unsigned int & int */ |
| 6262 | if (verbose) printf("test for unsigned int & int"); |
| 6263 | |
| 6264 | cod_assoc_externs(context, externs); |
| 6265 | cod_parse_for_context(extern_string, context); |
| 6266 | |
| 6267 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, int p2)", |
| 6268 | context); |
| 6269 | gen_code = cod_code_gen(code, context); |
| 6270 | proc = (unsigned int (*)(unsigned int, int))(long)gen_code->func; |
| 6271 | |
| 6272 | |
| 6273 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 6274 | unsigned int source1_u = src1u_vals[i]; |
| 6275 | for (j=0 ; j < sizeof(src2i_vals)/sizeof(src2i_vals[0]) ; j++) { |
| 6276 | int source2_i = src2i_vals[j]; |
| 6277 | |
| 6278 | unsigned int expected_result; |
| 6279 | unsigned int result; |
| 6280 | |
| 6281 | |
| 6282 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 6283 | |
| 6284 | expected_result = (unsigned int) (source1_u & source2_i); |
| 6285 | |
| 6286 | result = proc(source1_u, source2_i); |
| 6287 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 6288 | if (expected_result != result) { |
| 6289 | printf("Failed unsigned int & int test, expected %u, got %u, for %u & %d\n", |
| 6290 | expected_result, result, source1_u, source2_i); |
| 6291 | if (dumped == 0) cod_dump(gen_code); |
| 6292 | failed++; |
| 6293 | dumped++; |
| 6294 | } |
| 6295 | } |
| 6296 | } |
| 6297 | if (verbose) printf(" done\n"); |
| 6298 | cod_free_parse_context(context); |
| 6299 | cod_code_free(gen_code); |
| 6300 | } |
| 6301 | if ((only_run_test == NULL((void*)0)) || |
| 6302 | (strcmp(only_run_test, "u&u") == 0)) { |
| 6303 | int i, j; |
| 6304 | static char code[] = "{\n\ |
| 6305 | unsigned int a = p1;\n\ |
| 6306 | unsigned int b = p2;\n\ |
| 6307 | return a & b;\n\ |
| 6308 | }"; |
| 6309 | |
| 6310 | unsigned int (*proc)(unsigned int a, unsigned int b); |
| 6311 | cod_parse_context context = new_cod_parse_context(); |
| 6312 | int dumped = 0; |
| 6313 | |
| 6314 | cod_code gen_code; |
| 6315 | |
| 6316 | /* test for unsigned int & unsigned int */ |
| 6317 | if (verbose) printf("test for unsigned int & unsigned int"); |
| 6318 | |
| 6319 | cod_assoc_externs(context, externs); |
| 6320 | cod_parse_for_context(extern_string, context); |
| 6321 | |
| 6322 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, unsigned int p2)", |
| 6323 | context); |
| 6324 | gen_code = cod_code_gen(code, context); |
| 6325 | proc = (unsigned int (*)(unsigned int, unsigned int))(long)gen_code->func; |
| 6326 | |
| 6327 | |
| 6328 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 6329 | unsigned int source1_u = src1u_vals[i]; |
| 6330 | for (j=0 ; j < sizeof(src2u_vals)/sizeof(src2u_vals[0]) ; j++) { |
| 6331 | unsigned int source2_u = src2u_vals[j]; |
| 6332 | |
| 6333 | unsigned int expected_result; |
| 6334 | unsigned int result; |
| 6335 | |
| 6336 | |
| 6337 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 6338 | |
| 6339 | expected_result = (unsigned int) (source1_u & source2_u); |
| 6340 | |
| 6341 | result = proc(source1_u, source2_u); |
| 6342 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 6343 | if (expected_result != result) { |
| 6344 | printf("Failed unsigned int & unsigned int test, expected %u, got %u, for %u & %u\n", |
| 6345 | expected_result, result, source1_u, source2_u); |
| 6346 | if (dumped == 0) cod_dump(gen_code); |
| 6347 | failed++; |
| 6348 | dumped++; |
| 6349 | } |
| 6350 | } |
| 6351 | } |
| 6352 | if (verbose) printf(" done\n"); |
| 6353 | cod_free_parse_context(context); |
| 6354 | cod_code_free(gen_code); |
| 6355 | } |
| 6356 | if ((only_run_test == NULL((void*)0)) || |
| 6357 | (strcmp(only_run_test, "u&ul") == 0)) { |
| 6358 | int i, j; |
| 6359 | static char code[] = "{\n\ |
| 6360 | unsigned int a = p1;\n\ |
| 6361 | unsigned long b = p2;\n\ |
| 6362 | return a & b;\n\ |
| 6363 | }"; |
| 6364 | |
| 6365 | unsigned int (*proc)(unsigned int a, unsigned long b); |
| 6366 | cod_parse_context context = new_cod_parse_context(); |
| 6367 | int dumped = 0; |
| 6368 | |
| 6369 | cod_code gen_code; |
| 6370 | |
| 6371 | /* test for unsigned int & unsigned long */ |
| 6372 | if (verbose) printf("test for unsigned int & unsigned long"); |
| 6373 | |
| 6374 | cod_assoc_externs(context, externs); |
| 6375 | cod_parse_for_context(extern_string, context); |
| 6376 | |
| 6377 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, unsigned long p2)", |
| 6378 | context); |
| 6379 | gen_code = cod_code_gen(code, context); |
| 6380 | proc = (unsigned int (*)(unsigned int, unsigned long))(long)gen_code->func; |
| 6381 | |
| 6382 | |
| 6383 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 6384 | unsigned int source1_u = src1u_vals[i]; |
| 6385 | for (j=0 ; j < sizeof(src2ul_vals)/sizeof(src2ul_vals[0]) ; j++) { |
| 6386 | unsigned long source2_ul = src2ul_vals[j]; |
| 6387 | |
| 6388 | unsigned int expected_result; |
| 6389 | unsigned int result; |
| 6390 | |
| 6391 | |
| 6392 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 6393 | |
| 6394 | expected_result = (unsigned int) (source1_u & source2_ul); |
| 6395 | |
| 6396 | result = proc(source1_u, source2_ul); |
| 6397 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 6398 | if (expected_result != result) { |
| 6399 | printf("Failed unsigned int & unsigned long test, expected %u, got %u, for %u & %lu\n", |
| 6400 | expected_result, result, source1_u, source2_ul); |
| 6401 | if (dumped == 0) cod_dump(gen_code); |
| 6402 | failed++; |
| 6403 | dumped++; |
| 6404 | } |
| 6405 | } |
| 6406 | } |
| 6407 | if (verbose) printf(" done\n"); |
| 6408 | cod_free_parse_context(context); |
| 6409 | cod_code_free(gen_code); |
| 6410 | } |
| 6411 | if ((only_run_test == NULL((void*)0)) || |
| 6412 | (strcmp(only_run_test, "u&l") == 0)) { |
| 6413 | int i, j; |
| 6414 | static char code[] = "{\n\ |
| 6415 | unsigned int a = p1;\n\ |
| 6416 | long b = p2;\n\ |
| 6417 | return a & b;\n\ |
| 6418 | }"; |
| 6419 | |
| 6420 | unsigned int (*proc)(unsigned int a, long b); |
| 6421 | cod_parse_context context = new_cod_parse_context(); |
| 6422 | int dumped = 0; |
| 6423 | |
| 6424 | cod_code gen_code; |
| 6425 | |
| 6426 | /* test for unsigned int & long */ |
| 6427 | if (verbose) printf("test for unsigned int & long"); |
| 6428 | |
| 6429 | cod_assoc_externs(context, externs); |
| 6430 | cod_parse_for_context(extern_string, context); |
| 6431 | |
| 6432 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, long p2)", |
| 6433 | context); |
| 6434 | gen_code = cod_code_gen(code, context); |
| 6435 | proc = (unsigned int (*)(unsigned int, long))(long)gen_code->func; |
| 6436 | |
| 6437 | |
| 6438 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 6439 | unsigned int source1_u = src1u_vals[i]; |
| 6440 | for (j=0 ; j < sizeof(src2l_vals)/sizeof(src2l_vals[0]) ; j++) { |
| 6441 | long source2_l = src2l_vals[j]; |
| 6442 | |
| 6443 | unsigned int expected_result; |
| 6444 | unsigned int result; |
| 6445 | |
| 6446 | |
| 6447 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 6448 | |
| 6449 | expected_result = (unsigned int) (source1_u & source2_l); |
| 6450 | |
| 6451 | result = proc(source1_u, source2_l); |
| 6452 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 6453 | if (expected_result != result) { |
| 6454 | printf("Failed unsigned int & long test, expected %u, got %u, for %u & %ld\n", |
| 6455 | expected_result, result, source1_u, source2_l); |
| 6456 | if (dumped == 0) cod_dump(gen_code); |
| 6457 | failed++; |
| 6458 | dumped++; |
| 6459 | } |
| 6460 | } |
| 6461 | } |
| 6462 | if (verbose) printf(" done\n"); |
| 6463 | cod_free_parse_context(context); |
| 6464 | cod_code_free(gen_code); |
| 6465 | } |
| 6466 | } |
| 6467 | void and_ul_tests() |
| 6468 | { |
| 6469 | if ((only_run_test == NULL((void*)0)) || |
| 6470 | (strcmp(only_run_test, "ul&c") == 0)) { |
| 6471 | int i, j; |
| 6472 | static char code[] = "{\n\ |
| 6473 | unsigned long a = p1;\n\ |
| 6474 | signed char b = p2;\n\ |
| 6475 | return a & b;\n\ |
| 6476 | }"; |
| 6477 | |
| 6478 | unsigned long (*proc)(unsigned long a, signed char b); |
| 6479 | cod_parse_context context = new_cod_parse_context(); |
| 6480 | int dumped = 0; |
| 6481 | |
| 6482 | cod_code gen_code; |
| 6483 | |
| 6484 | /* test for unsigned long & signed char */ |
| 6485 | if (verbose) printf("test for unsigned long & signed char"); |
| 6486 | |
| 6487 | cod_assoc_externs(context, externs); |
| 6488 | cod_parse_for_context(extern_string, context); |
| 6489 | |
| 6490 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, signed char p2)", |
| 6491 | context); |
| 6492 | gen_code = cod_code_gen(code, context); |
| 6493 | proc = (unsigned long (*)(unsigned long, signed char))(long)gen_code->func; |
| 6494 | |
| 6495 | |
| 6496 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 6497 | unsigned long source1_ul = src1ul_vals[i]; |
| 6498 | for (j=0 ; j < sizeof(src2c_vals)/sizeof(src2c_vals[0]) ; j++) { |
| 6499 | signed char source2_c = src2c_vals[j]; |
| 6500 | |
| 6501 | unsigned long expected_result; |
| 6502 | unsigned long result; |
| 6503 | |
| 6504 | |
| 6505 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 6506 | |
| 6507 | expected_result = (unsigned long) (source1_ul & source2_c); |
| 6508 | |
| 6509 | result = proc(source1_ul, source2_c); |
| 6510 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 6511 | if (expected_result != result) { |
| 6512 | printf("Failed unsigned long & signed char test, expected %lu, got %lu, for %lu & %d\n", |
| 6513 | expected_result, result, source1_ul, source2_c); |
| 6514 | if (dumped == 0) cod_dump(gen_code); |
| 6515 | failed++; |
| 6516 | dumped++; |
| 6517 | } |
| 6518 | } |
| 6519 | } |
| 6520 | if (verbose) printf(" done\n"); |
| 6521 | cod_free_parse_context(context); |
| 6522 | cod_code_free(gen_code); |
| 6523 | } |
| 6524 | if ((only_run_test == NULL((void*)0)) || |
| 6525 | (strcmp(only_run_test, "ul&uc") == 0)) { |
| 6526 | int i, j; |
| 6527 | static char code[] = "{\n\ |
| 6528 | unsigned long a = p1;\n\ |
| 6529 | unsigned char b = p2;\n\ |
| 6530 | return a & b;\n\ |
| 6531 | }"; |
| 6532 | |
| 6533 | unsigned long (*proc)(unsigned long a, unsigned char b); |
| 6534 | cod_parse_context context = new_cod_parse_context(); |
| 6535 | int dumped = 0; |
| 6536 | |
| 6537 | cod_code gen_code; |
| 6538 | |
| 6539 | /* test for unsigned long & unsigned char */ |
| 6540 | if (verbose) printf("test for unsigned long & unsigned char"); |
| 6541 | |
| 6542 | cod_assoc_externs(context, externs); |
| 6543 | cod_parse_for_context(extern_string, context); |
| 6544 | |
| 6545 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, unsigned char p2)", |
| 6546 | context); |
| 6547 | gen_code = cod_code_gen(code, context); |
| 6548 | proc = (unsigned long (*)(unsigned long, unsigned char))(long)gen_code->func; |
| 6549 | |
| 6550 | |
| 6551 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 6552 | unsigned long source1_ul = src1ul_vals[i]; |
| 6553 | for (j=0 ; j < sizeof(src2uc_vals)/sizeof(src2uc_vals[0]) ; j++) { |
| 6554 | unsigned char source2_uc = src2uc_vals[j]; |
| 6555 | |
| 6556 | unsigned long expected_result; |
| 6557 | unsigned long result; |
| 6558 | |
| 6559 | |
| 6560 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 6561 | |
| 6562 | expected_result = (unsigned long) (source1_ul & source2_uc); |
| 6563 | |
| 6564 | result = proc(source1_ul, source2_uc); |
| 6565 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 6566 | if (expected_result != result) { |
| 6567 | printf("Failed unsigned long & unsigned char test, expected %lu, got %lu, for %lu & %u\n", |
| 6568 | expected_result, result, source1_ul, source2_uc); |
| 6569 | if (dumped == 0) cod_dump(gen_code); |
| 6570 | failed++; |
| 6571 | dumped++; |
| 6572 | } |
| 6573 | } |
| 6574 | } |
| 6575 | if (verbose) printf(" done\n"); |
| 6576 | cod_free_parse_context(context); |
| 6577 | cod_code_free(gen_code); |
| 6578 | } |
| 6579 | if ((only_run_test == NULL((void*)0)) || |
| 6580 | (strcmp(only_run_test, "ul&s") == 0)) { |
| 6581 | int i, j; |
| 6582 | static char code[] = "{\n\ |
| 6583 | unsigned long a = p1;\n\ |
| 6584 | short b = p2;\n\ |
| 6585 | return a & b;\n\ |
| 6586 | }"; |
| 6587 | |
| 6588 | unsigned long (*proc)(unsigned long a, short b); |
| 6589 | cod_parse_context context = new_cod_parse_context(); |
| 6590 | int dumped = 0; |
| 6591 | |
| 6592 | cod_code gen_code; |
| 6593 | |
| 6594 | /* test for unsigned long & short */ |
| 6595 | if (verbose) printf("test for unsigned long & short"); |
| 6596 | |
| 6597 | cod_assoc_externs(context, externs); |
| 6598 | cod_parse_for_context(extern_string, context); |
| 6599 | |
| 6600 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, short p2)", |
| 6601 | context); |
| 6602 | gen_code = cod_code_gen(code, context); |
| 6603 | proc = (unsigned long (*)(unsigned long, short))(long)gen_code->func; |
| 6604 | |
| 6605 | |
| 6606 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 6607 | unsigned long source1_ul = src1ul_vals[i]; |
| 6608 | for (j=0 ; j < sizeof(src2s_vals)/sizeof(src2s_vals[0]) ; j++) { |
| 6609 | short source2_s = src2s_vals[j]; |
| 6610 | |
| 6611 | unsigned long expected_result; |
| 6612 | unsigned long result; |
| 6613 | |
| 6614 | |
| 6615 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 6616 | |
| 6617 | expected_result = (unsigned long) (source1_ul & source2_s); |
| 6618 | |
| 6619 | result = proc(source1_ul, source2_s); |
| 6620 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 6621 | if (expected_result != result) { |
| 6622 | printf("Failed unsigned long & short test, expected %lu, got %lu, for %lu & %d\n", |
| 6623 | expected_result, result, source1_ul, source2_s); |
| 6624 | if (dumped == 0) cod_dump(gen_code); |
| 6625 | failed++; |
| 6626 | dumped++; |
| 6627 | } |
| 6628 | } |
| 6629 | } |
| 6630 | if (verbose) printf(" done\n"); |
| 6631 | cod_free_parse_context(context); |
| 6632 | cod_code_free(gen_code); |
| 6633 | } |
| 6634 | if ((only_run_test == NULL((void*)0)) || |
| 6635 | (strcmp(only_run_test, "ul&us") == 0)) { |
| 6636 | int i, j; |
| 6637 | static char code[] = "{\n\ |
| 6638 | unsigned long a = p1;\n\ |
| 6639 | unsigned short b = p2;\n\ |
| 6640 | return a & b;\n\ |
| 6641 | }"; |
| 6642 | |
| 6643 | unsigned long (*proc)(unsigned long a, unsigned short b); |
| 6644 | cod_parse_context context = new_cod_parse_context(); |
| 6645 | int dumped = 0; |
| 6646 | |
| 6647 | cod_code gen_code; |
| 6648 | |
| 6649 | /* test for unsigned long & unsigned short */ |
| 6650 | if (verbose) printf("test for unsigned long & unsigned short"); |
| 6651 | |
| 6652 | cod_assoc_externs(context, externs); |
| 6653 | cod_parse_for_context(extern_string, context); |
| 6654 | |
| 6655 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, unsigned short p2)", |
| 6656 | context); |
| 6657 | gen_code = cod_code_gen(code, context); |
| 6658 | proc = (unsigned long (*)(unsigned long, unsigned short))(long)gen_code->func; |
| 6659 | |
| 6660 | |
| 6661 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 6662 | unsigned long source1_ul = src1ul_vals[i]; |
| 6663 | for (j=0 ; j < sizeof(src2us_vals)/sizeof(src2us_vals[0]) ; j++) { |
| 6664 | unsigned short source2_us = src2us_vals[j]; |
| 6665 | |
| 6666 | unsigned long expected_result; |
| 6667 | unsigned long result; |
| 6668 | |
| 6669 | |
| 6670 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 6671 | |
| 6672 | expected_result = (unsigned long) (source1_ul & source2_us); |
| 6673 | |
| 6674 | result = proc(source1_ul, source2_us); |
| 6675 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 6676 | if (expected_result != result) { |
| 6677 | printf("Failed unsigned long & unsigned short test, expected %lu, got %lu, for %lu & %u\n", |
| 6678 | expected_result, result, source1_ul, source2_us); |
| 6679 | if (dumped == 0) cod_dump(gen_code); |
| 6680 | failed++; |
| 6681 | dumped++; |
| 6682 | } |
| 6683 | } |
| 6684 | } |
| 6685 | if (verbose) printf(" done\n"); |
| 6686 | cod_free_parse_context(context); |
| 6687 | cod_code_free(gen_code); |
| 6688 | } |
| 6689 | if ((only_run_test == NULL((void*)0)) || |
| 6690 | (strcmp(only_run_test, "ul&i") == 0)) { |
| 6691 | int i, j; |
| 6692 | static char code[] = "{\n\ |
| 6693 | unsigned long a = p1;\n\ |
| 6694 | int b = p2;\n\ |
| 6695 | return a & b;\n\ |
| 6696 | }"; |
| 6697 | |
| 6698 | unsigned long (*proc)(unsigned long a, int b); |
| 6699 | cod_parse_context context = new_cod_parse_context(); |
| 6700 | int dumped = 0; |
| 6701 | |
| 6702 | cod_code gen_code; |
| 6703 | |
| 6704 | /* test for unsigned long & int */ |
| 6705 | if (verbose) printf("test for unsigned long & int"); |
| 6706 | |
| 6707 | cod_assoc_externs(context, externs); |
| 6708 | cod_parse_for_context(extern_string, context); |
| 6709 | |
| 6710 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, int p2)", |
| 6711 | context); |
| 6712 | gen_code = cod_code_gen(code, context); |
| 6713 | proc = (unsigned long (*)(unsigned long, int))(long)gen_code->func; |
| 6714 | |
| 6715 | |
| 6716 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 6717 | unsigned long source1_ul = src1ul_vals[i]; |
| 6718 | for (j=0 ; j < sizeof(src2i_vals)/sizeof(src2i_vals[0]) ; j++) { |
| 6719 | int source2_i = src2i_vals[j]; |
| 6720 | |
| 6721 | unsigned long expected_result; |
| 6722 | unsigned long result; |
| 6723 | |
| 6724 | |
| 6725 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 6726 | |
| 6727 | expected_result = (unsigned long) (source1_ul & source2_i); |
| 6728 | |
| 6729 | result = proc(source1_ul, source2_i); |
| 6730 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 6731 | if (expected_result != result) { |
| 6732 | printf("Failed unsigned long & int test, expected %lu, got %lu, for %lu & %d\n", |
| 6733 | expected_result, result, source1_ul, source2_i); |
| 6734 | if (dumped == 0) cod_dump(gen_code); |
| 6735 | failed++; |
| 6736 | dumped++; |
| 6737 | } |
| 6738 | } |
| 6739 | } |
| 6740 | if (verbose) printf(" done\n"); |
| 6741 | cod_free_parse_context(context); |
| 6742 | cod_code_free(gen_code); |
| 6743 | } |
| 6744 | if ((only_run_test == NULL((void*)0)) || |
| 6745 | (strcmp(only_run_test, "ul&u") == 0)) { |
| 6746 | int i, j; |
| 6747 | static char code[] = "{\n\ |
| 6748 | unsigned long a = p1;\n\ |
| 6749 | unsigned int b = p2;\n\ |
| 6750 | return a & b;\n\ |
| 6751 | }"; |
| 6752 | |
| 6753 | unsigned long (*proc)(unsigned long a, unsigned int b); |
| 6754 | cod_parse_context context = new_cod_parse_context(); |
| 6755 | int dumped = 0; |
| 6756 | |
| 6757 | cod_code gen_code; |
| 6758 | |
| 6759 | /* test for unsigned long & unsigned int */ |
| 6760 | if (verbose) printf("test for unsigned long & unsigned int"); |
| 6761 | |
| 6762 | cod_assoc_externs(context, externs); |
| 6763 | cod_parse_for_context(extern_string, context); |
| 6764 | |
| 6765 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, unsigned int p2)", |
| 6766 | context); |
| 6767 | gen_code = cod_code_gen(code, context); |
| 6768 | proc = (unsigned long (*)(unsigned long, unsigned int))(long)gen_code->func; |
| 6769 | |
| 6770 | |
| 6771 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 6772 | unsigned long source1_ul = src1ul_vals[i]; |
| 6773 | for (j=0 ; j < sizeof(src2u_vals)/sizeof(src2u_vals[0]) ; j++) { |
| 6774 | unsigned int source2_u = src2u_vals[j]; |
| 6775 | |
| 6776 | unsigned long expected_result; |
| 6777 | unsigned long result; |
| 6778 | |
| 6779 | |
| 6780 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 6781 | |
| 6782 | expected_result = (unsigned long) (source1_ul & source2_u); |
| 6783 | |
| 6784 | result = proc(source1_ul, source2_u); |
| 6785 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 6786 | if (expected_result != result) { |
| 6787 | printf("Failed unsigned long & unsigned int test, expected %lu, got %lu, for %lu & %u\n", |
| 6788 | expected_result, result, source1_ul, source2_u); |
| 6789 | if (dumped == 0) cod_dump(gen_code); |
| 6790 | failed++; |
| 6791 | dumped++; |
| 6792 | } |
| 6793 | } |
| 6794 | } |
| 6795 | if (verbose) printf(" done\n"); |
| 6796 | cod_free_parse_context(context); |
| 6797 | cod_code_free(gen_code); |
| 6798 | } |
| 6799 | if ((only_run_test == NULL((void*)0)) || |
| 6800 | (strcmp(only_run_test, "ul&ul") == 0)) { |
| 6801 | int i, j; |
| 6802 | static char code[] = "{\n\ |
| 6803 | unsigned long a = p1;\n\ |
| 6804 | unsigned long b = p2;\n\ |
| 6805 | return a & b;\n\ |
| 6806 | }"; |
| 6807 | |
| 6808 | unsigned long (*proc)(unsigned long a, unsigned long b); |
| 6809 | cod_parse_context context = new_cod_parse_context(); |
| 6810 | int dumped = 0; |
| 6811 | |
| 6812 | cod_code gen_code; |
| 6813 | |
| 6814 | /* test for unsigned long & unsigned long */ |
| 6815 | if (verbose) printf("test for unsigned long & unsigned long"); |
| 6816 | |
| 6817 | cod_assoc_externs(context, externs); |
| 6818 | cod_parse_for_context(extern_string, context); |
| 6819 | |
| 6820 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, unsigned long p2)", |
| 6821 | context); |
| 6822 | gen_code = cod_code_gen(code, context); |
| 6823 | proc = (unsigned long (*)(unsigned long, unsigned long))(long)gen_code->func; |
| 6824 | |
| 6825 | |
| 6826 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 6827 | unsigned long source1_ul = src1ul_vals[i]; |
| 6828 | for (j=0 ; j < sizeof(src2ul_vals)/sizeof(src2ul_vals[0]) ; j++) { |
| 6829 | unsigned long source2_ul = src2ul_vals[j]; |
| 6830 | |
| 6831 | unsigned long expected_result; |
| 6832 | unsigned long result; |
| 6833 | |
| 6834 | |
| 6835 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 6836 | |
| 6837 | expected_result = (unsigned long) (source1_ul & source2_ul); |
| 6838 | |
| 6839 | result = proc(source1_ul, source2_ul); |
| 6840 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 6841 | if (expected_result != result) { |
| 6842 | printf("Failed unsigned long & unsigned long test, expected %lu, got %lu, for %lu & %lu\n", |
| 6843 | expected_result, result, source1_ul, source2_ul); |
| 6844 | if (dumped == 0) cod_dump(gen_code); |
| 6845 | failed++; |
| 6846 | dumped++; |
| 6847 | } |
| 6848 | } |
| 6849 | } |
| 6850 | if (verbose) printf(" done\n"); |
| 6851 | cod_free_parse_context(context); |
| 6852 | cod_code_free(gen_code); |
| 6853 | } |
| 6854 | if ((only_run_test == NULL((void*)0)) || |
| 6855 | (strcmp(only_run_test, "ul&l") == 0)) { |
| 6856 | int i, j; |
| 6857 | static char code[] = "{\n\ |
| 6858 | unsigned long a = p1;\n\ |
| 6859 | long b = p2;\n\ |
| 6860 | return a & b;\n\ |
| 6861 | }"; |
| 6862 | |
| 6863 | unsigned long (*proc)(unsigned long a, long b); |
| 6864 | cod_parse_context context = new_cod_parse_context(); |
| 6865 | int dumped = 0; |
| 6866 | |
| 6867 | cod_code gen_code; |
| 6868 | |
| 6869 | /* test for unsigned long & long */ |
| 6870 | if (verbose) printf("test for unsigned long & long"); |
| 6871 | |
| 6872 | cod_assoc_externs(context, externs); |
| 6873 | cod_parse_for_context(extern_string, context); |
| 6874 | |
| 6875 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, long p2)", |
| 6876 | context); |
| 6877 | gen_code = cod_code_gen(code, context); |
| 6878 | proc = (unsigned long (*)(unsigned long, long))(long)gen_code->func; |
| 6879 | |
| 6880 | |
| 6881 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 6882 | unsigned long source1_ul = src1ul_vals[i]; |
| 6883 | for (j=0 ; j < sizeof(src2l_vals)/sizeof(src2l_vals[0]) ; j++) { |
| 6884 | long source2_l = src2l_vals[j]; |
| 6885 | |
| 6886 | unsigned long expected_result; |
| 6887 | unsigned long result; |
| 6888 | |
| 6889 | |
| 6890 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 6891 | |
| 6892 | expected_result = (unsigned long) (source1_ul & source2_l); |
| 6893 | |
| 6894 | result = proc(source1_ul, source2_l); |
| 6895 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 6896 | if (expected_result != result) { |
| 6897 | printf("Failed unsigned long & long test, expected %lu, got %lu, for %lu & %ld\n", |
| 6898 | expected_result, result, source1_ul, source2_l); |
| 6899 | if (dumped == 0) cod_dump(gen_code); |
| 6900 | failed++; |
| 6901 | dumped++; |
| 6902 | } |
| 6903 | } |
| 6904 | } |
| 6905 | if (verbose) printf(" done\n"); |
| 6906 | cod_free_parse_context(context); |
| 6907 | cod_code_free(gen_code); |
| 6908 | } |
| 6909 | } |
| 6910 | void and_l_tests() |
| 6911 | { |
| 6912 | if ((only_run_test == NULL((void*)0)) || |
| 6913 | (strcmp(only_run_test, "l&c") == 0)) { |
| 6914 | int i, j; |
| 6915 | static char code[] = "{\n\ |
| 6916 | long a = p1;\n\ |
| 6917 | signed char b = p2;\n\ |
| 6918 | return a & b;\n\ |
| 6919 | }"; |
| 6920 | |
| 6921 | long (*proc)(long a, signed char b); |
| 6922 | cod_parse_context context = new_cod_parse_context(); |
| 6923 | int dumped = 0; |
| 6924 | |
| 6925 | cod_code gen_code; |
| 6926 | |
| 6927 | /* test for long & signed char */ |
| 6928 | if (verbose) printf("test for long & signed char"); |
| 6929 | |
| 6930 | cod_assoc_externs(context, externs); |
| 6931 | cod_parse_for_context(extern_string, context); |
| 6932 | |
| 6933 | cod_subroutine_declaration("long proc(long p1, signed char p2)", |
| 6934 | context); |
| 6935 | gen_code = cod_code_gen(code, context); |
| 6936 | proc = (long (*)(long, signed char))(long)gen_code->func; |
| 6937 | |
| 6938 | |
| 6939 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 6940 | long source1_l = src1l_vals[i]; |
| 6941 | for (j=0 ; j < sizeof(src2c_vals)/sizeof(src2c_vals[0]) ; j++) { |
| 6942 | signed char source2_c = src2c_vals[j]; |
| 6943 | |
| 6944 | long expected_result; |
| 6945 | long result; |
| 6946 | |
| 6947 | |
| 6948 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 6949 | |
| 6950 | expected_result = (long) (source1_l & source2_c); |
| 6951 | |
| 6952 | result = proc(source1_l, source2_c); |
| 6953 | if (expected_result != result) { |
| 6954 | printf("Failed long & signed char test, expected %ld, got %ld, for %ld & %d\n", |
| 6955 | expected_result, result, source1_l, source2_c); |
| 6956 | if (dumped == 0) cod_dump(gen_code); |
| 6957 | failed++; |
| 6958 | dumped++; |
| 6959 | } |
| 6960 | } |
| 6961 | } |
| 6962 | if (verbose) printf(" done\n"); |
| 6963 | cod_free_parse_context(context); |
| 6964 | cod_code_free(gen_code); |
| 6965 | } |
| 6966 | if ((only_run_test == NULL((void*)0)) || |
| 6967 | (strcmp(only_run_test, "l&uc") == 0)) { |
| 6968 | int i, j; |
| 6969 | static char code[] = "{\n\ |
| 6970 | long a = p1;\n\ |
| 6971 | unsigned char b = p2;\n\ |
| 6972 | return a & b;\n\ |
| 6973 | }"; |
| 6974 | |
| 6975 | long (*proc)(long a, unsigned char b); |
| 6976 | cod_parse_context context = new_cod_parse_context(); |
| 6977 | int dumped = 0; |
| 6978 | |
| 6979 | cod_code gen_code; |
| 6980 | |
| 6981 | /* test for long & unsigned char */ |
| 6982 | if (verbose) printf("test for long & unsigned char"); |
| 6983 | |
| 6984 | cod_assoc_externs(context, externs); |
| 6985 | cod_parse_for_context(extern_string, context); |
| 6986 | |
| 6987 | cod_subroutine_declaration("long proc(long p1, unsigned char p2)", |
| 6988 | context); |
| 6989 | gen_code = cod_code_gen(code, context); |
| 6990 | proc = (long (*)(long, unsigned char))(long)gen_code->func; |
| 6991 | |
| 6992 | |
| 6993 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 6994 | long source1_l = src1l_vals[i]; |
| 6995 | for (j=0 ; j < sizeof(src2uc_vals)/sizeof(src2uc_vals[0]) ; j++) { |
| 6996 | unsigned char source2_uc = src2uc_vals[j]; |
| 6997 | |
| 6998 | long expected_result; |
| 6999 | long result; |
| 7000 | |
| 7001 | |
| 7002 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 7003 | |
| 7004 | expected_result = (long) (source1_l & source2_uc); |
| 7005 | |
| 7006 | result = proc(source1_l, source2_uc); |
| 7007 | if (expected_result != result) { |
| 7008 | printf("Failed long & unsigned char test, expected %ld, got %ld, for %ld & %u\n", |
| 7009 | expected_result, result, source1_l, source2_uc); |
| 7010 | if (dumped == 0) cod_dump(gen_code); |
| 7011 | failed++; |
| 7012 | dumped++; |
| 7013 | } |
| 7014 | } |
| 7015 | } |
| 7016 | if (verbose) printf(" done\n"); |
| 7017 | cod_free_parse_context(context); |
| 7018 | cod_code_free(gen_code); |
| 7019 | } |
| 7020 | if ((only_run_test == NULL((void*)0)) || |
| 7021 | (strcmp(only_run_test, "l&s") == 0)) { |
| 7022 | int i, j; |
| 7023 | static char code[] = "{\n\ |
| 7024 | long a = p1;\n\ |
| 7025 | short b = p2;\n\ |
| 7026 | return a & b;\n\ |
| 7027 | }"; |
| 7028 | |
| 7029 | long (*proc)(long a, short b); |
| 7030 | cod_parse_context context = new_cod_parse_context(); |
| 7031 | int dumped = 0; |
| 7032 | |
| 7033 | cod_code gen_code; |
| 7034 | |
| 7035 | /* test for long & short */ |
| 7036 | if (verbose) printf("test for long & short"); |
| 7037 | |
| 7038 | cod_assoc_externs(context, externs); |
| 7039 | cod_parse_for_context(extern_string, context); |
| 7040 | |
| 7041 | cod_subroutine_declaration("long proc(long p1, short p2)", |
| 7042 | context); |
| 7043 | gen_code = cod_code_gen(code, context); |
| 7044 | proc = (long (*)(long, short))(long)gen_code->func; |
| 7045 | |
| 7046 | |
| 7047 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 7048 | long source1_l = src1l_vals[i]; |
| 7049 | for (j=0 ; j < sizeof(src2s_vals)/sizeof(src2s_vals[0]) ; j++) { |
| 7050 | short source2_s = src2s_vals[j]; |
| 7051 | |
| 7052 | long expected_result; |
| 7053 | long result; |
| 7054 | |
| 7055 | |
| 7056 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 7057 | |
| 7058 | expected_result = (long) (source1_l & source2_s); |
| 7059 | |
| 7060 | result = proc(source1_l, source2_s); |
| 7061 | if (expected_result != result) { |
| 7062 | printf("Failed long & short test, expected %ld, got %ld, for %ld & %d\n", |
| 7063 | expected_result, result, source1_l, source2_s); |
| 7064 | if (dumped == 0) cod_dump(gen_code); |
| 7065 | failed++; |
| 7066 | dumped++; |
| 7067 | } |
| 7068 | } |
| 7069 | } |
| 7070 | if (verbose) printf(" done\n"); |
| 7071 | cod_free_parse_context(context); |
| 7072 | cod_code_free(gen_code); |
| 7073 | } |
| 7074 | if ((only_run_test == NULL((void*)0)) || |
| 7075 | (strcmp(only_run_test, "l&us") == 0)) { |
| 7076 | int i, j; |
| 7077 | static char code[] = "{\n\ |
| 7078 | long a = p1;\n\ |
| 7079 | unsigned short b = p2;\n\ |
| 7080 | return a & b;\n\ |
| 7081 | }"; |
| 7082 | |
| 7083 | long (*proc)(long a, unsigned short b); |
| 7084 | cod_parse_context context = new_cod_parse_context(); |
| 7085 | int dumped = 0; |
| 7086 | |
| 7087 | cod_code gen_code; |
| 7088 | |
| 7089 | /* test for long & unsigned short */ |
| 7090 | if (verbose) printf("test for long & unsigned short"); |
| 7091 | |
| 7092 | cod_assoc_externs(context, externs); |
| 7093 | cod_parse_for_context(extern_string, context); |
| 7094 | |
| 7095 | cod_subroutine_declaration("long proc(long p1, unsigned short p2)", |
| 7096 | context); |
| 7097 | gen_code = cod_code_gen(code, context); |
| 7098 | proc = (long (*)(long, unsigned short))(long)gen_code->func; |
| 7099 | |
| 7100 | |
| 7101 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 7102 | long source1_l = src1l_vals[i]; |
| 7103 | for (j=0 ; j < sizeof(src2us_vals)/sizeof(src2us_vals[0]) ; j++) { |
| 7104 | unsigned short source2_us = src2us_vals[j]; |
| 7105 | |
| 7106 | long expected_result; |
| 7107 | long result; |
| 7108 | |
| 7109 | |
| 7110 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 7111 | |
| 7112 | expected_result = (long) (source1_l & source2_us); |
| 7113 | |
| 7114 | result = proc(source1_l, source2_us); |
| 7115 | if (expected_result != result) { |
| 7116 | printf("Failed long & unsigned short test, expected %ld, got %ld, for %ld & %u\n", |
| 7117 | expected_result, result, source1_l, source2_us); |
| 7118 | if (dumped == 0) cod_dump(gen_code); |
| 7119 | failed++; |
| 7120 | dumped++; |
| 7121 | } |
| 7122 | } |
| 7123 | } |
| 7124 | if (verbose) printf(" done\n"); |
| 7125 | cod_free_parse_context(context); |
| 7126 | cod_code_free(gen_code); |
| 7127 | } |
| 7128 | if ((only_run_test == NULL((void*)0)) || |
| 7129 | (strcmp(only_run_test, "l&i") == 0)) { |
| 7130 | int i, j; |
| 7131 | static char code[] = "{\n\ |
| 7132 | long a = p1;\n\ |
| 7133 | int b = p2;\n\ |
| 7134 | return a & b;\n\ |
| 7135 | }"; |
| 7136 | |
| 7137 | long (*proc)(long a, int b); |
| 7138 | cod_parse_context context = new_cod_parse_context(); |
| 7139 | int dumped = 0; |
| 7140 | |
| 7141 | cod_code gen_code; |
| 7142 | |
| 7143 | /* test for long & int */ |
| 7144 | if (verbose) printf("test for long & int"); |
| 7145 | |
| 7146 | cod_assoc_externs(context, externs); |
| 7147 | cod_parse_for_context(extern_string, context); |
| 7148 | |
| 7149 | cod_subroutine_declaration("long proc(long p1, int p2)", |
| 7150 | context); |
| 7151 | gen_code = cod_code_gen(code, context); |
| 7152 | proc = (long (*)(long, int))(long)gen_code->func; |
| 7153 | |
| 7154 | |
| 7155 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 7156 | long source1_l = src1l_vals[i]; |
| 7157 | for (j=0 ; j < sizeof(src2i_vals)/sizeof(src2i_vals[0]) ; j++) { |
| 7158 | int source2_i = src2i_vals[j]; |
| 7159 | |
| 7160 | long expected_result; |
| 7161 | long result; |
| 7162 | |
| 7163 | |
| 7164 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 7165 | |
| 7166 | expected_result = (long) (source1_l & source2_i); |
| 7167 | |
| 7168 | result = proc(source1_l, source2_i); |
| 7169 | if (expected_result != result) { |
| 7170 | printf("Failed long & int test, expected %ld, got %ld, for %ld & %d\n", |
| 7171 | expected_result, result, source1_l, source2_i); |
| 7172 | if (dumped == 0) cod_dump(gen_code); |
| 7173 | failed++; |
| 7174 | dumped++; |
| 7175 | } |
| 7176 | } |
| 7177 | } |
| 7178 | if (verbose) printf(" done\n"); |
| 7179 | cod_free_parse_context(context); |
| 7180 | cod_code_free(gen_code); |
| 7181 | } |
| 7182 | if ((only_run_test == NULL((void*)0)) || |
| 7183 | (strcmp(only_run_test, "l&u") == 0)) { |
| 7184 | int i, j; |
| 7185 | static char code[] = "{\n\ |
| 7186 | long a = p1;\n\ |
| 7187 | unsigned int b = p2;\n\ |
| 7188 | return a & b;\n\ |
| 7189 | }"; |
| 7190 | |
| 7191 | long (*proc)(long a, unsigned int b); |
| 7192 | cod_parse_context context = new_cod_parse_context(); |
| 7193 | int dumped = 0; |
| 7194 | |
| 7195 | cod_code gen_code; |
| 7196 | |
| 7197 | /* test for long & unsigned int */ |
| 7198 | if (verbose) printf("test for long & unsigned int"); |
| 7199 | |
| 7200 | cod_assoc_externs(context, externs); |
| 7201 | cod_parse_for_context(extern_string, context); |
| 7202 | |
| 7203 | cod_subroutine_declaration("long proc(long p1, unsigned int p2)", |
| 7204 | context); |
| 7205 | gen_code = cod_code_gen(code, context); |
| 7206 | proc = (long (*)(long, unsigned int))(long)gen_code->func; |
| 7207 | |
| 7208 | |
| 7209 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 7210 | long source1_l = src1l_vals[i]; |
| 7211 | for (j=0 ; j < sizeof(src2u_vals)/sizeof(src2u_vals[0]) ; j++) { |
| 7212 | unsigned int source2_u = src2u_vals[j]; |
| 7213 | |
| 7214 | long expected_result; |
| 7215 | long result; |
| 7216 | |
| 7217 | |
| 7218 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 7219 | |
| 7220 | expected_result = (long) (source1_l & source2_u); |
| 7221 | |
| 7222 | result = proc(source1_l, source2_u); |
| 7223 | if (expected_result != result) { |
| 7224 | printf("Failed long & unsigned int test, expected %ld, got %ld, for %ld & %u\n", |
| 7225 | expected_result, result, source1_l, source2_u); |
| 7226 | if (dumped == 0) cod_dump(gen_code); |
| 7227 | failed++; |
| 7228 | dumped++; |
| 7229 | } |
| 7230 | } |
| 7231 | } |
| 7232 | if (verbose) printf(" done\n"); |
| 7233 | cod_free_parse_context(context); |
| 7234 | cod_code_free(gen_code); |
| 7235 | } |
| 7236 | if ((only_run_test == NULL((void*)0)) || |
| 7237 | (strcmp(only_run_test, "l&ul") == 0)) { |
| 7238 | int i, j; |
| 7239 | static char code[] = "{\n\ |
| 7240 | long a = p1;\n\ |
| 7241 | unsigned long b = p2;\n\ |
| 7242 | return a & b;\n\ |
| 7243 | }"; |
| 7244 | |
| 7245 | long (*proc)(long a, unsigned long b); |
| 7246 | cod_parse_context context = new_cod_parse_context(); |
| 7247 | int dumped = 0; |
| 7248 | |
| 7249 | cod_code gen_code; |
| 7250 | |
| 7251 | /* test for long & unsigned long */ |
| 7252 | if (verbose) printf("test for long & unsigned long"); |
| 7253 | |
| 7254 | cod_assoc_externs(context, externs); |
| 7255 | cod_parse_for_context(extern_string, context); |
| 7256 | |
| 7257 | cod_subroutine_declaration("long proc(long p1, unsigned long p2)", |
| 7258 | context); |
| 7259 | gen_code = cod_code_gen(code, context); |
| 7260 | proc = (long (*)(long, unsigned long))(long)gen_code->func; |
| 7261 | |
| 7262 | |
| 7263 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 7264 | long source1_l = src1l_vals[i]; |
| 7265 | for (j=0 ; j < sizeof(src2ul_vals)/sizeof(src2ul_vals[0]) ; j++) { |
| 7266 | unsigned long source2_ul = src2ul_vals[j]; |
| 7267 | |
| 7268 | long expected_result; |
| 7269 | long result; |
| 7270 | |
| 7271 | |
| 7272 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 7273 | |
| 7274 | expected_result = (long) (source1_l & source2_ul); |
| 7275 | |
| 7276 | result = proc(source1_l, source2_ul); |
| 7277 | if (expected_result != result) { |
| 7278 | printf("Failed long & unsigned long test, expected %ld, got %ld, for %ld & %lu\n", |
| 7279 | expected_result, result, source1_l, source2_ul); |
| 7280 | if (dumped == 0) cod_dump(gen_code); |
| 7281 | failed++; |
| 7282 | dumped++; |
| 7283 | } |
| 7284 | } |
| 7285 | } |
| 7286 | if (verbose) printf(" done\n"); |
| 7287 | cod_free_parse_context(context); |
| 7288 | cod_code_free(gen_code); |
| 7289 | } |
| 7290 | if ((only_run_test == NULL((void*)0)) || |
| 7291 | (strcmp(only_run_test, "l&l") == 0)) { |
| 7292 | int i, j; |
| 7293 | static char code[] = "{\n\ |
| 7294 | long a = p1;\n\ |
| 7295 | long b = p2;\n\ |
| 7296 | return a & b;\n\ |
| 7297 | }"; |
| 7298 | |
| 7299 | long (*proc)(long a, long b); |
| 7300 | cod_parse_context context = new_cod_parse_context(); |
| 7301 | int dumped = 0; |
| 7302 | |
| 7303 | cod_code gen_code; |
| 7304 | |
| 7305 | /* test for long & long */ |
| 7306 | if (verbose) printf("test for long & long"); |
| 7307 | |
| 7308 | cod_assoc_externs(context, externs); |
| 7309 | cod_parse_for_context(extern_string, context); |
| 7310 | |
| 7311 | cod_subroutine_declaration("long proc(long p1, long p2)", |
| 7312 | context); |
| 7313 | gen_code = cod_code_gen(code, context); |
| 7314 | proc = (long (*)(long, long))(long)gen_code->func; |
| 7315 | |
| 7316 | |
| 7317 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 7318 | long source1_l = src1l_vals[i]; |
| 7319 | for (j=0 ; j < sizeof(src2l_vals)/sizeof(src2l_vals[0]) ; j++) { |
| 7320 | long source2_l = src2l_vals[j]; |
| 7321 | |
| 7322 | long expected_result; |
| 7323 | long result; |
| 7324 | |
| 7325 | |
| 7326 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 7327 | |
| 7328 | expected_result = (long) (source1_l & source2_l); |
| 7329 | |
| 7330 | result = proc(source1_l, source2_l); |
| 7331 | if (expected_result != result) { |
| 7332 | printf("Failed long & long test, expected %ld, got %ld, for %ld & %ld\n", |
| 7333 | expected_result, result, source1_l, source2_l); |
| 7334 | if (dumped == 0) cod_dump(gen_code); |
| 7335 | failed++; |
| 7336 | dumped++; |
| 7337 | } |
| 7338 | } |
| 7339 | } |
| 7340 | if (verbose) printf(" done\n"); |
| 7341 | cod_free_parse_context(context); |
| 7342 | cod_code_free(gen_code); |
| 7343 | } |
| 7344 | } |
| 7345 | void or_c_tests() |
| 7346 | { |
| 7347 | if ((only_run_test == NULL((void*)0)) || |
| 7348 | (strcmp(only_run_test, "c|c") == 0)) { |
| 7349 | int i, j; |
| 7350 | static char code[] = "{\n\ |
| 7351 | signed char a = p1;\n\ |
| 7352 | signed char b = p2;\n\ |
| 7353 | return a | b;\n\ |
| 7354 | }"; |
| 7355 | |
| 7356 | signed char (*proc)(signed char a, signed char b); |
| 7357 | cod_parse_context context = new_cod_parse_context(); |
| 7358 | int dumped = 0; |
| 7359 | |
| 7360 | cod_code gen_code; |
| 7361 | |
| 7362 | /* test for signed char | signed char */ |
| 7363 | if (verbose) printf("test for signed char | signed char"); |
| 7364 | |
| 7365 | cod_assoc_externs(context, externs); |
| 7366 | cod_parse_for_context(extern_string, context); |
| 7367 | |
| 7368 | cod_subroutine_declaration("signed char proc(signed char p1, signed char p2)", |
| 7369 | context); |
| 7370 | gen_code = cod_code_gen(code, context); |
| 7371 | proc = (signed char (*)(signed char, signed char))(long)gen_code->func; |
| 7372 | |
| 7373 | |
| 7374 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 7375 | signed char source1_c = src1c_vals[i]; |
| 7376 | for (j=0 ; j < sizeof(src2c_vals)/sizeof(src2c_vals[0]) ; j++) { |
| 7377 | signed char source2_c = src2c_vals[j]; |
| 7378 | |
| 7379 | signed char expected_result; |
| 7380 | signed char result; |
| 7381 | |
| 7382 | |
| 7383 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 7384 | |
| 7385 | expected_result = (signed char) (source1_c | source2_c); |
| 7386 | |
| 7387 | result = proc(source1_c, source2_c); |
| 7388 | if (expected_result != result) { |
| 7389 | printf("Failed signed char | signed char test, expected %d, got %d, for %d | %d\n", |
| 7390 | expected_result, result, source1_c, source2_c); |
| 7391 | if (dumped == 0) cod_dump(gen_code); |
| 7392 | failed++; |
| 7393 | dumped++; |
| 7394 | } |
| 7395 | } |
| 7396 | } |
| 7397 | if (verbose) printf(" done\n"); |
| 7398 | cod_free_parse_context(context); |
| 7399 | cod_code_free(gen_code); |
| 7400 | } |
| 7401 | if ((only_run_test == NULL((void*)0)) || |
| 7402 | (strcmp(only_run_test, "c|uc") == 0)) { |
| 7403 | int i, j; |
| 7404 | static char code[] = "{\n\ |
| 7405 | signed char a = p1;\n\ |
| 7406 | unsigned char b = p2;\n\ |
| 7407 | return a | b;\n\ |
| 7408 | }"; |
| 7409 | |
| 7410 | signed char (*proc)(signed char a, unsigned char b); |
| 7411 | cod_parse_context context = new_cod_parse_context(); |
| 7412 | int dumped = 0; |
| 7413 | |
| 7414 | cod_code gen_code; |
| 7415 | |
| 7416 | /* test for signed char | unsigned char */ |
| 7417 | if (verbose) printf("test for signed char | unsigned char"); |
| 7418 | |
| 7419 | cod_assoc_externs(context, externs); |
| 7420 | cod_parse_for_context(extern_string, context); |
| 7421 | |
| 7422 | cod_subroutine_declaration("signed char proc(signed char p1, unsigned char p2)", |
| 7423 | context); |
| 7424 | gen_code = cod_code_gen(code, context); |
| 7425 | proc = (signed char (*)(signed char, unsigned char))(long)gen_code->func; |
| 7426 | |
| 7427 | |
| 7428 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 7429 | signed char source1_c = src1c_vals[i]; |
| 7430 | for (j=0 ; j < sizeof(src2uc_vals)/sizeof(src2uc_vals[0]) ; j++) { |
| 7431 | unsigned char source2_uc = src2uc_vals[j]; |
| 7432 | |
| 7433 | signed char expected_result; |
| 7434 | signed char result; |
| 7435 | |
| 7436 | |
| 7437 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 7438 | |
| 7439 | expected_result = (signed char) (source1_c | source2_uc); |
| 7440 | |
| 7441 | result = proc(source1_c, source2_uc); |
| 7442 | if (expected_result != result) { |
| 7443 | printf("Failed signed char | unsigned char test, expected %d, got %d, for %d | %u\n", |
| 7444 | expected_result, result, source1_c, source2_uc); |
| 7445 | if (dumped == 0) cod_dump(gen_code); |
| 7446 | failed++; |
| 7447 | dumped++; |
| 7448 | } |
| 7449 | } |
| 7450 | } |
| 7451 | if (verbose) printf(" done\n"); |
| 7452 | cod_free_parse_context(context); |
| 7453 | cod_code_free(gen_code); |
| 7454 | } |
| 7455 | if ((only_run_test == NULL((void*)0)) || |
| 7456 | (strcmp(only_run_test, "c|s") == 0)) { |
| 7457 | int i, j; |
| 7458 | static char code[] = "{\n\ |
| 7459 | signed char a = p1;\n\ |
| 7460 | short b = p2;\n\ |
| 7461 | return a | b;\n\ |
| 7462 | }"; |
| 7463 | |
| 7464 | signed char (*proc)(signed char a, short b); |
| 7465 | cod_parse_context context = new_cod_parse_context(); |
| 7466 | int dumped = 0; |
| 7467 | |
| 7468 | cod_code gen_code; |
| 7469 | |
| 7470 | /* test for signed char | short */ |
| 7471 | if (verbose) printf("test for signed char | short"); |
| 7472 | |
| 7473 | cod_assoc_externs(context, externs); |
| 7474 | cod_parse_for_context(extern_string, context); |
| 7475 | |
| 7476 | cod_subroutine_declaration("signed char proc(signed char p1, short p2)", |
| 7477 | context); |
| 7478 | gen_code = cod_code_gen(code, context); |
| 7479 | proc = (signed char (*)(signed char, short))(long)gen_code->func; |
| 7480 | |
| 7481 | |
| 7482 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 7483 | signed char source1_c = src1c_vals[i]; |
| 7484 | for (j=0 ; j < sizeof(src2s_vals)/sizeof(src2s_vals[0]) ; j++) { |
| 7485 | short source2_s = src2s_vals[j]; |
| 7486 | |
| 7487 | signed char expected_result; |
| 7488 | signed char result; |
| 7489 | |
| 7490 | |
| 7491 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 7492 | |
| 7493 | expected_result = (signed char) (source1_c | source2_s); |
| 7494 | |
| 7495 | result = proc(source1_c, source2_s); |
| 7496 | if (expected_result != result) { |
| 7497 | printf("Failed signed char | short test, expected %d, got %d, for %d | %d\n", |
| 7498 | expected_result, result, source1_c, source2_s); |
| 7499 | if (dumped == 0) cod_dump(gen_code); |
| 7500 | failed++; |
| 7501 | dumped++; |
| 7502 | } |
| 7503 | } |
| 7504 | } |
| 7505 | if (verbose) printf(" done\n"); |
| 7506 | cod_free_parse_context(context); |
| 7507 | cod_code_free(gen_code); |
| 7508 | } |
| 7509 | if ((only_run_test == NULL((void*)0)) || |
| 7510 | (strcmp(only_run_test, "c|us") == 0)) { |
| 7511 | int i, j; |
| 7512 | static char code[] = "{\n\ |
| 7513 | signed char a = p1;\n\ |
| 7514 | unsigned short b = p2;\n\ |
| 7515 | return a | b;\n\ |
| 7516 | }"; |
| 7517 | |
| 7518 | signed char (*proc)(signed char a, unsigned short b); |
| 7519 | cod_parse_context context = new_cod_parse_context(); |
| 7520 | int dumped = 0; |
| 7521 | |
| 7522 | cod_code gen_code; |
| 7523 | |
| 7524 | /* test for signed char | unsigned short */ |
| 7525 | if (verbose) printf("test for signed char | unsigned short"); |
| 7526 | |
| 7527 | cod_assoc_externs(context, externs); |
| 7528 | cod_parse_for_context(extern_string, context); |
| 7529 | |
| 7530 | cod_subroutine_declaration("signed char proc(signed char p1, unsigned short p2)", |
| 7531 | context); |
| 7532 | gen_code = cod_code_gen(code, context); |
| 7533 | proc = (signed char (*)(signed char, unsigned short))(long)gen_code->func; |
| 7534 | |
| 7535 | |
| 7536 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 7537 | signed char source1_c = src1c_vals[i]; |
| 7538 | for (j=0 ; j < sizeof(src2us_vals)/sizeof(src2us_vals[0]) ; j++) { |
| 7539 | unsigned short source2_us = src2us_vals[j]; |
| 7540 | |
| 7541 | signed char expected_result; |
| 7542 | signed char result; |
| 7543 | |
| 7544 | |
| 7545 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 7546 | |
| 7547 | expected_result = (signed char) (source1_c | source2_us); |
| 7548 | |
| 7549 | result = proc(source1_c, source2_us); |
| 7550 | if (expected_result != result) { |
| 7551 | printf("Failed signed char | unsigned short test, expected %d, got %d, for %d | %u\n", |
| 7552 | expected_result, result, source1_c, source2_us); |
| 7553 | if (dumped == 0) cod_dump(gen_code); |
| 7554 | failed++; |
| 7555 | dumped++; |
| 7556 | } |
| 7557 | } |
| 7558 | } |
| 7559 | if (verbose) printf(" done\n"); |
| 7560 | cod_free_parse_context(context); |
| 7561 | cod_code_free(gen_code); |
| 7562 | } |
| 7563 | if ((only_run_test == NULL((void*)0)) || |
| 7564 | (strcmp(only_run_test, "c|i") == 0)) { |
| 7565 | int i, j; |
| 7566 | static char code[] = "{\n\ |
| 7567 | signed char a = p1;\n\ |
| 7568 | int b = p2;\n\ |
| 7569 | return a | b;\n\ |
| 7570 | }"; |
| 7571 | |
| 7572 | signed char (*proc)(signed char a, int b); |
| 7573 | cod_parse_context context = new_cod_parse_context(); |
| 7574 | int dumped = 0; |
| 7575 | |
| 7576 | cod_code gen_code; |
| 7577 | |
| 7578 | /* test for signed char | int */ |
| 7579 | if (verbose) printf("test for signed char | int"); |
| 7580 | |
| 7581 | cod_assoc_externs(context, externs); |
| 7582 | cod_parse_for_context(extern_string, context); |
| 7583 | |
| 7584 | cod_subroutine_declaration("signed char proc(signed char p1, int p2)", |
| 7585 | context); |
| 7586 | gen_code = cod_code_gen(code, context); |
| 7587 | proc = (signed char (*)(signed char, int))(long)gen_code->func; |
| 7588 | |
| 7589 | |
| 7590 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 7591 | signed char source1_c = src1c_vals[i]; |
| 7592 | for (j=0 ; j < sizeof(src2i_vals)/sizeof(src2i_vals[0]) ; j++) { |
| 7593 | int source2_i = src2i_vals[j]; |
| 7594 | |
| 7595 | signed char expected_result; |
| 7596 | signed char result; |
| 7597 | |
| 7598 | |
| 7599 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 7600 | |
| 7601 | expected_result = (signed char) (source1_c | source2_i); |
| 7602 | |
| 7603 | result = proc(source1_c, source2_i); |
| 7604 | if (expected_result != result) { |
| 7605 | printf("Failed signed char | int test, expected %d, got %d, for %d | %d\n", |
| 7606 | expected_result, result, source1_c, source2_i); |
| 7607 | if (dumped == 0) cod_dump(gen_code); |
| 7608 | failed++; |
| 7609 | dumped++; |
| 7610 | } |
| 7611 | } |
| 7612 | } |
| 7613 | if (verbose) printf(" done\n"); |
| 7614 | cod_free_parse_context(context); |
| 7615 | cod_code_free(gen_code); |
| 7616 | } |
| 7617 | if ((only_run_test == NULL((void*)0)) || |
| 7618 | (strcmp(only_run_test, "c|u") == 0)) { |
| 7619 | int i, j; |
| 7620 | static char code[] = "{\n\ |
| 7621 | signed char a = p1;\n\ |
| 7622 | unsigned int b = p2;\n\ |
| 7623 | return a | b;\n\ |
| 7624 | }"; |
| 7625 | |
| 7626 | signed char (*proc)(signed char a, unsigned int b); |
| 7627 | cod_parse_context context = new_cod_parse_context(); |
| 7628 | int dumped = 0; |
| 7629 | |
| 7630 | cod_code gen_code; |
| 7631 | |
| 7632 | /* test for signed char | unsigned int */ |
| 7633 | if (verbose) printf("test for signed char | unsigned int"); |
| 7634 | |
| 7635 | cod_assoc_externs(context, externs); |
| 7636 | cod_parse_for_context(extern_string, context); |
| 7637 | |
| 7638 | cod_subroutine_declaration("signed char proc(signed char p1, unsigned int p2)", |
| 7639 | context); |
| 7640 | gen_code = cod_code_gen(code, context); |
| 7641 | proc = (signed char (*)(signed char, unsigned int))(long)gen_code->func; |
| 7642 | |
| 7643 | |
| 7644 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 7645 | signed char source1_c = src1c_vals[i]; |
| 7646 | for (j=0 ; j < sizeof(src2u_vals)/sizeof(src2u_vals[0]) ; j++) { |
| 7647 | unsigned int source2_u = src2u_vals[j]; |
| 7648 | |
| 7649 | signed char expected_result; |
| 7650 | signed char result; |
| 7651 | |
| 7652 | |
| 7653 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 7654 | |
| 7655 | expected_result = (signed char) (source1_c | source2_u); |
| 7656 | |
| 7657 | result = proc(source1_c, source2_u); |
| 7658 | if (expected_result != result) { |
| 7659 | printf("Failed signed char | unsigned int test, expected %d, got %d, for %d | %u\n", |
| 7660 | expected_result, result, source1_c, source2_u); |
| 7661 | if (dumped == 0) cod_dump(gen_code); |
| 7662 | failed++; |
| 7663 | dumped++; |
| 7664 | } |
| 7665 | } |
| 7666 | } |
| 7667 | if (verbose) printf(" done\n"); |
| 7668 | cod_free_parse_context(context); |
| 7669 | cod_code_free(gen_code); |
| 7670 | } |
| 7671 | if ((only_run_test == NULL((void*)0)) || |
| 7672 | (strcmp(only_run_test, "c|ul") == 0)) { |
| 7673 | int i, j; |
| 7674 | static char code[] = "{\n\ |
| 7675 | signed char a = p1;\n\ |
| 7676 | unsigned long b = p2;\n\ |
| 7677 | return a | b;\n\ |
| 7678 | }"; |
| 7679 | |
| 7680 | signed char (*proc)(signed char a, unsigned long b); |
| 7681 | cod_parse_context context = new_cod_parse_context(); |
| 7682 | int dumped = 0; |
| 7683 | |
| 7684 | cod_code gen_code; |
| 7685 | |
| 7686 | /* test for signed char | unsigned long */ |
| 7687 | if (verbose) printf("test for signed char | unsigned long"); |
| 7688 | |
| 7689 | cod_assoc_externs(context, externs); |
| 7690 | cod_parse_for_context(extern_string, context); |
| 7691 | |
| 7692 | cod_subroutine_declaration("signed char proc(signed char p1, unsigned long p2)", |
| 7693 | context); |
| 7694 | gen_code = cod_code_gen(code, context); |
| 7695 | proc = (signed char (*)(signed char, unsigned long))(long)gen_code->func; |
| 7696 | |
| 7697 | |
| 7698 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 7699 | signed char source1_c = src1c_vals[i]; |
| 7700 | for (j=0 ; j < sizeof(src2ul_vals)/sizeof(src2ul_vals[0]) ; j++) { |
| 7701 | unsigned long source2_ul = src2ul_vals[j]; |
| 7702 | |
| 7703 | signed char expected_result; |
| 7704 | signed char result; |
| 7705 | |
| 7706 | |
| 7707 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 7708 | |
| 7709 | expected_result = (signed char) (source1_c | source2_ul); |
| 7710 | |
| 7711 | result = proc(source1_c, source2_ul); |
| 7712 | if (expected_result != result) { |
| 7713 | printf("Failed signed char | unsigned long test, expected %d, got %d, for %d | %lu\n", |
| 7714 | expected_result, result, source1_c, source2_ul); |
| 7715 | if (dumped == 0) cod_dump(gen_code); |
| 7716 | failed++; |
| 7717 | dumped++; |
| 7718 | } |
| 7719 | } |
| 7720 | } |
| 7721 | if (verbose) printf(" done\n"); |
| 7722 | cod_free_parse_context(context); |
| 7723 | cod_code_free(gen_code); |
| 7724 | } |
| 7725 | if ((only_run_test == NULL((void*)0)) || |
| 7726 | (strcmp(only_run_test, "c|l") == 0)) { |
| 7727 | int i, j; |
| 7728 | static char code[] = "{\n\ |
| 7729 | signed char a = p1;\n\ |
| 7730 | long b = p2;\n\ |
| 7731 | return a | b;\n\ |
| 7732 | }"; |
| 7733 | |
| 7734 | signed char (*proc)(signed char a, long b); |
| 7735 | cod_parse_context context = new_cod_parse_context(); |
| 7736 | int dumped = 0; |
| 7737 | |
| 7738 | cod_code gen_code; |
| 7739 | |
| 7740 | /* test for signed char | long */ |
| 7741 | if (verbose) printf("test for signed char | long"); |
| 7742 | |
| 7743 | cod_assoc_externs(context, externs); |
| 7744 | cod_parse_for_context(extern_string, context); |
| 7745 | |
| 7746 | cod_subroutine_declaration("signed char proc(signed char p1, long p2)", |
| 7747 | context); |
| 7748 | gen_code = cod_code_gen(code, context); |
| 7749 | proc = (signed char (*)(signed char, long))(long)gen_code->func; |
| 7750 | |
| 7751 | |
| 7752 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 7753 | signed char source1_c = src1c_vals[i]; |
| 7754 | for (j=0 ; j < sizeof(src2l_vals)/sizeof(src2l_vals[0]) ; j++) { |
| 7755 | long source2_l = src2l_vals[j]; |
| 7756 | |
| 7757 | signed char expected_result; |
| 7758 | signed char result; |
| 7759 | |
| 7760 | |
| 7761 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 7762 | |
| 7763 | expected_result = (signed char) (source1_c | source2_l); |
| 7764 | |
| 7765 | result = proc(source1_c, source2_l); |
| 7766 | if (expected_result != result) { |
| 7767 | printf("Failed signed char | long test, expected %d, got %d, for %d | %ld\n", |
| 7768 | expected_result, result, source1_c, source2_l); |
| 7769 | if (dumped == 0) cod_dump(gen_code); |
| 7770 | failed++; |
| 7771 | dumped++; |
| 7772 | } |
| 7773 | } |
| 7774 | } |
| 7775 | if (verbose) printf(" done\n"); |
| 7776 | cod_free_parse_context(context); |
| 7777 | cod_code_free(gen_code); |
| 7778 | } |
| 7779 | } |
| 7780 | void or_uc_tests() |
| 7781 | { |
| 7782 | if ((only_run_test == NULL((void*)0)) || |
| 7783 | (strcmp(only_run_test, "uc|c") == 0)) { |
| 7784 | int i, j; |
| 7785 | static char code[] = "{\n\ |
| 7786 | unsigned char a = p1;\n\ |
| 7787 | signed char b = p2;\n\ |
| 7788 | return a | b;\n\ |
| 7789 | }"; |
| 7790 | |
| 7791 | unsigned char (*proc)(unsigned char a, signed char b); |
| 7792 | cod_parse_context context = new_cod_parse_context(); |
| 7793 | int dumped = 0; |
| 7794 | |
| 7795 | cod_code gen_code; |
| 7796 | |
| 7797 | /* test for unsigned char | signed char */ |
| 7798 | if (verbose) printf("test for unsigned char | signed char"); |
| 7799 | |
| 7800 | cod_assoc_externs(context, externs); |
| 7801 | cod_parse_for_context(extern_string, context); |
| 7802 | |
| 7803 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, signed char p2)", |
| 7804 | context); |
| 7805 | gen_code = cod_code_gen(code, context); |
| 7806 | proc = (unsigned char (*)(unsigned char, signed char))(long)gen_code->func; |
| 7807 | |
| 7808 | |
| 7809 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 7810 | unsigned char source1_uc = src1uc_vals[i]; |
| 7811 | for (j=0 ; j < sizeof(src2c_vals)/sizeof(src2c_vals[0]) ; j++) { |
| 7812 | signed char source2_c = src2c_vals[j]; |
| 7813 | |
| 7814 | unsigned char expected_result; |
| 7815 | unsigned char result; |
| 7816 | |
| 7817 | |
| 7818 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 7819 | |
| 7820 | expected_result = (unsigned char) (source1_uc | source2_c); |
| 7821 | |
| 7822 | result = proc(source1_uc, source2_c); |
| 7823 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 7824 | if (expected_result != result) { |
| 7825 | printf("Failed unsigned char | signed char test, expected %u, got %u, for %u | %d\n", |
| 7826 | expected_result, result, source1_uc, source2_c); |
| 7827 | if (dumped == 0) cod_dump(gen_code); |
| 7828 | failed++; |
| 7829 | dumped++; |
| 7830 | } |
| 7831 | } |
| 7832 | } |
| 7833 | if (verbose) printf(" done\n"); |
| 7834 | cod_free_parse_context(context); |
| 7835 | cod_code_free(gen_code); |
| 7836 | } |
| 7837 | if ((only_run_test == NULL((void*)0)) || |
| 7838 | (strcmp(only_run_test, "uc|uc") == 0)) { |
| 7839 | int i, j; |
| 7840 | static char code[] = "{\n\ |
| 7841 | unsigned char a = p1;\n\ |
| 7842 | unsigned char b = p2;\n\ |
| 7843 | return a | b;\n\ |
| 7844 | }"; |
| 7845 | |
| 7846 | unsigned char (*proc)(unsigned char a, unsigned char b); |
| 7847 | cod_parse_context context = new_cod_parse_context(); |
| 7848 | int dumped = 0; |
| 7849 | |
| 7850 | cod_code gen_code; |
| 7851 | |
| 7852 | /* test for unsigned char | unsigned char */ |
| 7853 | if (verbose) printf("test for unsigned char | unsigned char"); |
| 7854 | |
| 7855 | cod_assoc_externs(context, externs); |
| 7856 | cod_parse_for_context(extern_string, context); |
| 7857 | |
| 7858 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, unsigned char p2)", |
| 7859 | context); |
| 7860 | gen_code = cod_code_gen(code, context); |
| 7861 | proc = (unsigned char (*)(unsigned char, unsigned char))(long)gen_code->func; |
| 7862 | |
| 7863 | |
| 7864 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 7865 | unsigned char source1_uc = src1uc_vals[i]; |
| 7866 | for (j=0 ; j < sizeof(src2uc_vals)/sizeof(src2uc_vals[0]) ; j++) { |
| 7867 | unsigned char source2_uc = src2uc_vals[j]; |
| 7868 | |
| 7869 | unsigned char expected_result; |
| 7870 | unsigned char result; |
| 7871 | |
| 7872 | |
| 7873 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 7874 | |
| 7875 | expected_result = (unsigned char) (source1_uc | source2_uc); |
| 7876 | |
| 7877 | result = proc(source1_uc, source2_uc); |
| 7878 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 7879 | if (expected_result != result) { |
| 7880 | printf("Failed unsigned char | unsigned char test, expected %u, got %u, for %u | %u\n", |
| 7881 | expected_result, result, source1_uc, source2_uc); |
| 7882 | if (dumped == 0) cod_dump(gen_code); |
| 7883 | failed++; |
| 7884 | dumped++; |
| 7885 | } |
| 7886 | } |
| 7887 | } |
| 7888 | if (verbose) printf(" done\n"); |
| 7889 | cod_free_parse_context(context); |
| 7890 | cod_code_free(gen_code); |
| 7891 | } |
| 7892 | if ((only_run_test == NULL((void*)0)) || |
| 7893 | (strcmp(only_run_test, "uc|s") == 0)) { |
| 7894 | int i, j; |
| 7895 | static char code[] = "{\n\ |
| 7896 | unsigned char a = p1;\n\ |
| 7897 | short b = p2;\n\ |
| 7898 | return a | b;\n\ |
| 7899 | }"; |
| 7900 | |
| 7901 | unsigned char (*proc)(unsigned char a, short b); |
| 7902 | cod_parse_context context = new_cod_parse_context(); |
| 7903 | int dumped = 0; |
| 7904 | |
| 7905 | cod_code gen_code; |
| 7906 | |
| 7907 | /* test for unsigned char | short */ |
| 7908 | if (verbose) printf("test for unsigned char | short"); |
| 7909 | |
| 7910 | cod_assoc_externs(context, externs); |
| 7911 | cod_parse_for_context(extern_string, context); |
| 7912 | |
| 7913 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, short p2)", |
| 7914 | context); |
| 7915 | gen_code = cod_code_gen(code, context); |
| 7916 | proc = (unsigned char (*)(unsigned char, short))(long)gen_code->func; |
| 7917 | |
| 7918 | |
| 7919 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 7920 | unsigned char source1_uc = src1uc_vals[i]; |
| 7921 | for (j=0 ; j < sizeof(src2s_vals)/sizeof(src2s_vals[0]) ; j++) { |
| 7922 | short source2_s = src2s_vals[j]; |
| 7923 | |
| 7924 | unsigned char expected_result; |
| 7925 | unsigned char result; |
| 7926 | |
| 7927 | |
| 7928 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 7929 | |
| 7930 | expected_result = (unsigned char) (source1_uc | source2_s); |
| 7931 | |
| 7932 | result = proc(source1_uc, source2_s); |
| 7933 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 7934 | if (expected_result != result) { |
| 7935 | printf("Failed unsigned char | short test, expected %u, got %u, for %u | %d\n", |
| 7936 | expected_result, result, source1_uc, source2_s); |
| 7937 | if (dumped == 0) cod_dump(gen_code); |
| 7938 | failed++; |
| 7939 | dumped++; |
| 7940 | } |
| 7941 | } |
| 7942 | } |
| 7943 | if (verbose) printf(" done\n"); |
| 7944 | cod_free_parse_context(context); |
| 7945 | cod_code_free(gen_code); |
| 7946 | } |
| 7947 | if ((only_run_test == NULL((void*)0)) || |
| 7948 | (strcmp(only_run_test, "uc|us") == 0)) { |
| 7949 | int i, j; |
| 7950 | static char code[] = "{\n\ |
| 7951 | unsigned char a = p1;\n\ |
| 7952 | unsigned short b = p2;\n\ |
| 7953 | return a | b;\n\ |
| 7954 | }"; |
| 7955 | |
| 7956 | unsigned char (*proc)(unsigned char a, unsigned short b); |
| 7957 | cod_parse_context context = new_cod_parse_context(); |
| 7958 | int dumped = 0; |
| 7959 | |
| 7960 | cod_code gen_code; |
| 7961 | |
| 7962 | /* test for unsigned char | unsigned short */ |
| 7963 | if (verbose) printf("test for unsigned char | unsigned short"); |
| 7964 | |
| 7965 | cod_assoc_externs(context, externs); |
| 7966 | cod_parse_for_context(extern_string, context); |
| 7967 | |
| 7968 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, unsigned short p2)", |
| 7969 | context); |
| 7970 | gen_code = cod_code_gen(code, context); |
| 7971 | proc = (unsigned char (*)(unsigned char, unsigned short))(long)gen_code->func; |
| 7972 | |
| 7973 | |
| 7974 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 7975 | unsigned char source1_uc = src1uc_vals[i]; |
| 7976 | for (j=0 ; j < sizeof(src2us_vals)/sizeof(src2us_vals[0]) ; j++) { |
| 7977 | unsigned short source2_us = src2us_vals[j]; |
| 7978 | |
| 7979 | unsigned char expected_result; |
| 7980 | unsigned char result; |
| 7981 | |
| 7982 | |
| 7983 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 7984 | |
| 7985 | expected_result = (unsigned char) (source1_uc | source2_us); |
| 7986 | |
| 7987 | result = proc(source1_uc, source2_us); |
| 7988 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 7989 | if (expected_result != result) { |
| 7990 | printf("Failed unsigned char | unsigned short test, expected %u, got %u, for %u | %u\n", |
| 7991 | expected_result, result, source1_uc, source2_us); |
| 7992 | if (dumped == 0) cod_dump(gen_code); |
| 7993 | failed++; |
| 7994 | dumped++; |
| 7995 | } |
| 7996 | } |
| 7997 | } |
| 7998 | if (verbose) printf(" done\n"); |
| 7999 | cod_free_parse_context(context); |
| 8000 | cod_code_free(gen_code); |
| 8001 | } |
| 8002 | if ((only_run_test == NULL((void*)0)) || |
| 8003 | (strcmp(only_run_test, "uc|i") == 0)) { |
| 8004 | int i, j; |
| 8005 | static char code[] = "{\n\ |
| 8006 | unsigned char a = p1;\n\ |
| 8007 | int b = p2;\n\ |
| 8008 | return a | b;\n\ |
| 8009 | }"; |
| 8010 | |
| 8011 | unsigned char (*proc)(unsigned char a, int b); |
| 8012 | cod_parse_context context = new_cod_parse_context(); |
| 8013 | int dumped = 0; |
| 8014 | |
| 8015 | cod_code gen_code; |
| 8016 | |
| 8017 | /* test for unsigned char | int */ |
| 8018 | if (verbose) printf("test for unsigned char | int"); |
| 8019 | |
| 8020 | cod_assoc_externs(context, externs); |
| 8021 | cod_parse_for_context(extern_string, context); |
| 8022 | |
| 8023 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, int p2)", |
| 8024 | context); |
| 8025 | gen_code = cod_code_gen(code, context); |
| 8026 | proc = (unsigned char (*)(unsigned char, int))(long)gen_code->func; |
| 8027 | |
| 8028 | |
| 8029 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 8030 | unsigned char source1_uc = src1uc_vals[i]; |
| 8031 | for (j=0 ; j < sizeof(src2i_vals)/sizeof(src2i_vals[0]) ; j++) { |
| 8032 | int source2_i = src2i_vals[j]; |
| 8033 | |
| 8034 | unsigned char expected_result; |
| 8035 | unsigned char result; |
| 8036 | |
| 8037 | |
| 8038 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 8039 | |
| 8040 | expected_result = (unsigned char) (source1_uc | source2_i); |
| 8041 | |
| 8042 | result = proc(source1_uc, source2_i); |
| 8043 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 8044 | if (expected_result != result) { |
| 8045 | printf("Failed unsigned char | int test, expected %u, got %u, for %u | %d\n", |
| 8046 | expected_result, result, source1_uc, source2_i); |
| 8047 | if (dumped == 0) cod_dump(gen_code); |
| 8048 | failed++; |
| 8049 | dumped++; |
| 8050 | } |
| 8051 | } |
| 8052 | } |
| 8053 | if (verbose) printf(" done\n"); |
| 8054 | cod_free_parse_context(context); |
| 8055 | cod_code_free(gen_code); |
| 8056 | } |
| 8057 | if ((only_run_test == NULL((void*)0)) || |
| 8058 | (strcmp(only_run_test, "uc|u") == 0)) { |
| 8059 | int i, j; |
| 8060 | static char code[] = "{\n\ |
| 8061 | unsigned char a = p1;\n\ |
| 8062 | unsigned int b = p2;\n\ |
| 8063 | return a | b;\n\ |
| 8064 | }"; |
| 8065 | |
| 8066 | unsigned char (*proc)(unsigned char a, unsigned int b); |
| 8067 | cod_parse_context context = new_cod_parse_context(); |
| 8068 | int dumped = 0; |
| 8069 | |
| 8070 | cod_code gen_code; |
| 8071 | |
| 8072 | /* test for unsigned char | unsigned int */ |
| 8073 | if (verbose) printf("test for unsigned char | unsigned int"); |
| 8074 | |
| 8075 | cod_assoc_externs(context, externs); |
| 8076 | cod_parse_for_context(extern_string, context); |
| 8077 | |
| 8078 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, unsigned int p2)", |
| 8079 | context); |
| 8080 | gen_code = cod_code_gen(code, context); |
| 8081 | proc = (unsigned char (*)(unsigned char, unsigned int))(long)gen_code->func; |
| 8082 | |
| 8083 | |
| 8084 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 8085 | unsigned char source1_uc = src1uc_vals[i]; |
| 8086 | for (j=0 ; j < sizeof(src2u_vals)/sizeof(src2u_vals[0]) ; j++) { |
| 8087 | unsigned int source2_u = src2u_vals[j]; |
| 8088 | |
| 8089 | unsigned char expected_result; |
| 8090 | unsigned char result; |
| 8091 | |
| 8092 | |
| 8093 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 8094 | |
| 8095 | expected_result = (unsigned char) (source1_uc | source2_u); |
| 8096 | |
| 8097 | result = proc(source1_uc, source2_u); |
| 8098 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 8099 | if (expected_result != result) { |
| 8100 | printf("Failed unsigned char | unsigned int test, expected %u, got %u, for %u | %u\n", |
| 8101 | expected_result, result, source1_uc, source2_u); |
| 8102 | if (dumped == 0) cod_dump(gen_code); |
| 8103 | failed++; |
| 8104 | dumped++; |
| 8105 | } |
| 8106 | } |
| 8107 | } |
| 8108 | if (verbose) printf(" done\n"); |
| 8109 | cod_free_parse_context(context); |
| 8110 | cod_code_free(gen_code); |
| 8111 | } |
| 8112 | if ((only_run_test == NULL((void*)0)) || |
| 8113 | (strcmp(only_run_test, "uc|ul") == 0)) { |
| 8114 | int i, j; |
| 8115 | static char code[] = "{\n\ |
| 8116 | unsigned char a = p1;\n\ |
| 8117 | unsigned long b = p2;\n\ |
| 8118 | return a | b;\n\ |
| 8119 | }"; |
| 8120 | |
| 8121 | unsigned char (*proc)(unsigned char a, unsigned long b); |
| 8122 | cod_parse_context context = new_cod_parse_context(); |
| 8123 | int dumped = 0; |
| 8124 | |
| 8125 | cod_code gen_code; |
| 8126 | |
| 8127 | /* test for unsigned char | unsigned long */ |
| 8128 | if (verbose) printf("test for unsigned char | unsigned long"); |
| 8129 | |
| 8130 | cod_assoc_externs(context, externs); |
| 8131 | cod_parse_for_context(extern_string, context); |
| 8132 | |
| 8133 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, unsigned long p2)", |
| 8134 | context); |
| 8135 | gen_code = cod_code_gen(code, context); |
| 8136 | proc = (unsigned char (*)(unsigned char, unsigned long))(long)gen_code->func; |
| 8137 | |
| 8138 | |
| 8139 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 8140 | unsigned char source1_uc = src1uc_vals[i]; |
| 8141 | for (j=0 ; j < sizeof(src2ul_vals)/sizeof(src2ul_vals[0]) ; j++) { |
| 8142 | unsigned long source2_ul = src2ul_vals[j]; |
| 8143 | |
| 8144 | unsigned char expected_result; |
| 8145 | unsigned char result; |
| 8146 | |
| 8147 | |
| 8148 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 8149 | |
| 8150 | expected_result = (unsigned char) (source1_uc | source2_ul); |
| 8151 | |
| 8152 | result = proc(source1_uc, source2_ul); |
| 8153 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 8154 | if (expected_result != result) { |
| 8155 | printf("Failed unsigned char | unsigned long test, expected %u, got %u, for %u | %lu\n", |
| 8156 | expected_result, result, source1_uc, source2_ul); |
| 8157 | if (dumped == 0) cod_dump(gen_code); |
| 8158 | failed++; |
| 8159 | dumped++; |
| 8160 | } |
| 8161 | } |
| 8162 | } |
| 8163 | if (verbose) printf(" done\n"); |
| 8164 | cod_free_parse_context(context); |
| 8165 | cod_code_free(gen_code); |
| 8166 | } |
| 8167 | if ((only_run_test == NULL((void*)0)) || |
| 8168 | (strcmp(only_run_test, "uc|l") == 0)) { |
| 8169 | int i, j; |
| 8170 | static char code[] = "{\n\ |
| 8171 | unsigned char a = p1;\n\ |
| 8172 | long b = p2;\n\ |
| 8173 | return a | b;\n\ |
| 8174 | }"; |
| 8175 | |
| 8176 | unsigned char (*proc)(unsigned char a, long b); |
| 8177 | cod_parse_context context = new_cod_parse_context(); |
| 8178 | int dumped = 0; |
| 8179 | |
| 8180 | cod_code gen_code; |
| 8181 | |
| 8182 | /* test for unsigned char | long */ |
| 8183 | if (verbose) printf("test for unsigned char | long"); |
| 8184 | |
| 8185 | cod_assoc_externs(context, externs); |
| 8186 | cod_parse_for_context(extern_string, context); |
| 8187 | |
| 8188 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, long p2)", |
| 8189 | context); |
| 8190 | gen_code = cod_code_gen(code, context); |
| 8191 | proc = (unsigned char (*)(unsigned char, long))(long)gen_code->func; |
| 8192 | |
| 8193 | |
| 8194 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 8195 | unsigned char source1_uc = src1uc_vals[i]; |
| 8196 | for (j=0 ; j < sizeof(src2l_vals)/sizeof(src2l_vals[0]) ; j++) { |
| 8197 | long source2_l = src2l_vals[j]; |
| 8198 | |
| 8199 | unsigned char expected_result; |
| 8200 | unsigned char result; |
| 8201 | |
| 8202 | |
| 8203 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 8204 | |
| 8205 | expected_result = (unsigned char) (source1_uc | source2_l); |
| 8206 | |
| 8207 | result = proc(source1_uc, source2_l); |
| 8208 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 8209 | if (expected_result != result) { |
| 8210 | printf("Failed unsigned char | long test, expected %u, got %u, for %u | %ld\n", |
| 8211 | expected_result, result, source1_uc, source2_l); |
| 8212 | if (dumped == 0) cod_dump(gen_code); |
| 8213 | failed++; |
| 8214 | dumped++; |
| 8215 | } |
| 8216 | } |
| 8217 | } |
| 8218 | if (verbose) printf(" done\n"); |
| 8219 | cod_free_parse_context(context); |
| 8220 | cod_code_free(gen_code); |
| 8221 | } |
| 8222 | } |
| 8223 | void or_s_tests() |
| 8224 | { |
| 8225 | if ((only_run_test == NULL((void*)0)) || |
| 8226 | (strcmp(only_run_test, "s|c") == 0)) { |
| 8227 | int i, j; |
| 8228 | static char code[] = "{\n\ |
| 8229 | short a = p1;\n\ |
| 8230 | signed char b = p2;\n\ |
| 8231 | return a | b;\n\ |
| 8232 | }"; |
| 8233 | |
| 8234 | short (*proc)(short a, signed char b); |
| 8235 | cod_parse_context context = new_cod_parse_context(); |
| 8236 | int dumped = 0; |
| 8237 | |
| 8238 | cod_code gen_code; |
| 8239 | |
| 8240 | /* test for short | signed char */ |
| 8241 | if (verbose) printf("test for short | signed char"); |
| 8242 | |
| 8243 | cod_assoc_externs(context, externs); |
| 8244 | cod_parse_for_context(extern_string, context); |
| 8245 | |
| 8246 | cod_subroutine_declaration("short proc(short p1, signed char p2)", |
| 8247 | context); |
| 8248 | gen_code = cod_code_gen(code, context); |
| 8249 | proc = (short (*)(short, signed char))(long)gen_code->func; |
| 8250 | |
| 8251 | |
| 8252 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 8253 | short source1_s = src1s_vals[i]; |
| 8254 | for (j=0 ; j < sizeof(src2c_vals)/sizeof(src2c_vals[0]) ; j++) { |
| 8255 | signed char source2_c = src2c_vals[j]; |
| 8256 | |
| 8257 | short expected_result; |
| 8258 | short result; |
| 8259 | |
| 8260 | |
| 8261 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 8262 | |
| 8263 | expected_result = (short) (source1_s | source2_c); |
| 8264 | |
| 8265 | result = proc(source1_s, source2_c); |
| 8266 | if (expected_result != result) { |
| 8267 | printf("Failed short | signed char test, expected %d, got %d, for %d | %d\n", |
| 8268 | expected_result, result, source1_s, source2_c); |
| 8269 | if (dumped == 0) cod_dump(gen_code); |
| 8270 | failed++; |
| 8271 | dumped++; |
| 8272 | } |
| 8273 | } |
| 8274 | } |
| 8275 | if (verbose) printf(" done\n"); |
| 8276 | cod_free_parse_context(context); |
| 8277 | cod_code_free(gen_code); |
| 8278 | } |
| 8279 | if ((only_run_test == NULL((void*)0)) || |
| 8280 | (strcmp(only_run_test, "s|uc") == 0)) { |
| 8281 | int i, j; |
| 8282 | static char code[] = "{\n\ |
| 8283 | short a = p1;\n\ |
| 8284 | unsigned char b = p2;\n\ |
| 8285 | return a | b;\n\ |
| 8286 | }"; |
| 8287 | |
| 8288 | short (*proc)(short a, unsigned char b); |
| 8289 | cod_parse_context context = new_cod_parse_context(); |
| 8290 | int dumped = 0; |
| 8291 | |
| 8292 | cod_code gen_code; |
| 8293 | |
| 8294 | /* test for short | unsigned char */ |
| 8295 | if (verbose) printf("test for short | unsigned char"); |
| 8296 | |
| 8297 | cod_assoc_externs(context, externs); |
| 8298 | cod_parse_for_context(extern_string, context); |
| 8299 | |
| 8300 | cod_subroutine_declaration("short proc(short p1, unsigned char p2)", |
| 8301 | context); |
| 8302 | gen_code = cod_code_gen(code, context); |
| 8303 | proc = (short (*)(short, unsigned char))(long)gen_code->func; |
| 8304 | |
| 8305 | |
| 8306 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 8307 | short source1_s = src1s_vals[i]; |
| 8308 | for (j=0 ; j < sizeof(src2uc_vals)/sizeof(src2uc_vals[0]) ; j++) { |
| 8309 | unsigned char source2_uc = src2uc_vals[j]; |
| 8310 | |
| 8311 | short expected_result; |
| 8312 | short result; |
| 8313 | |
| 8314 | |
| 8315 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 8316 | |
| 8317 | expected_result = (short) (source1_s | source2_uc); |
| 8318 | |
| 8319 | result = proc(source1_s, source2_uc); |
| 8320 | if (expected_result != result) { |
| 8321 | printf("Failed short | unsigned char test, expected %d, got %d, for %d | %u\n", |
| 8322 | expected_result, result, source1_s, source2_uc); |
| 8323 | if (dumped == 0) cod_dump(gen_code); |
| 8324 | failed++; |
| 8325 | dumped++; |
| 8326 | } |
| 8327 | } |
| 8328 | } |
| 8329 | if (verbose) printf(" done\n"); |
| 8330 | cod_free_parse_context(context); |
| 8331 | cod_code_free(gen_code); |
| 8332 | } |
| 8333 | if ((only_run_test == NULL((void*)0)) || |
| 8334 | (strcmp(only_run_test, "s|s") == 0)) { |
| 8335 | int i, j; |
| 8336 | static char code[] = "{\n\ |
| 8337 | short a = p1;\n\ |
| 8338 | short b = p2;\n\ |
| 8339 | return a | b;\n\ |
| 8340 | }"; |
| 8341 | |
| 8342 | short (*proc)(short a, short b); |
| 8343 | cod_parse_context context = new_cod_parse_context(); |
| 8344 | int dumped = 0; |
| 8345 | |
| 8346 | cod_code gen_code; |
| 8347 | |
| 8348 | /* test for short | short */ |
| 8349 | if (verbose) printf("test for short | short"); |
| 8350 | |
| 8351 | cod_assoc_externs(context, externs); |
| 8352 | cod_parse_for_context(extern_string, context); |
| 8353 | |
| 8354 | cod_subroutine_declaration("short proc(short p1, short p2)", |
| 8355 | context); |
| 8356 | gen_code = cod_code_gen(code, context); |
| 8357 | proc = (short (*)(short, short))(long)gen_code->func; |
| 8358 | |
| 8359 | |
| 8360 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 8361 | short source1_s = src1s_vals[i]; |
| 8362 | for (j=0 ; j < sizeof(src2s_vals)/sizeof(src2s_vals[0]) ; j++) { |
| 8363 | short source2_s = src2s_vals[j]; |
| 8364 | |
| 8365 | short expected_result; |
| 8366 | short result; |
| 8367 | |
| 8368 | |
| 8369 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 8370 | |
| 8371 | expected_result = (short) (source1_s | source2_s); |
| 8372 | |
| 8373 | result = proc(source1_s, source2_s); |
| 8374 | if (expected_result != result) { |
| 8375 | printf("Failed short | short test, expected %d, got %d, for %d | %d\n", |
| 8376 | expected_result, result, source1_s, source2_s); |
| 8377 | if (dumped == 0) cod_dump(gen_code); |
| 8378 | failed++; |
| 8379 | dumped++; |
| 8380 | } |
| 8381 | } |
| 8382 | } |
| 8383 | if (verbose) printf(" done\n"); |
| 8384 | cod_free_parse_context(context); |
| 8385 | cod_code_free(gen_code); |
| 8386 | } |
| 8387 | if ((only_run_test == NULL((void*)0)) || |
| 8388 | (strcmp(only_run_test, "s|us") == 0)) { |
| 8389 | int i, j; |
| 8390 | static char code[] = "{\n\ |
| 8391 | short a = p1;\n\ |
| 8392 | unsigned short b = p2;\n\ |
| 8393 | return a | b;\n\ |
| 8394 | }"; |
| 8395 | |
| 8396 | short (*proc)(short a, unsigned short b); |
| 8397 | cod_parse_context context = new_cod_parse_context(); |
| 8398 | int dumped = 0; |
| 8399 | |
| 8400 | cod_code gen_code; |
| 8401 | |
| 8402 | /* test for short | unsigned short */ |
| 8403 | if (verbose) printf("test for short | unsigned short"); |
| 8404 | |
| 8405 | cod_assoc_externs(context, externs); |
| 8406 | cod_parse_for_context(extern_string, context); |
| 8407 | |
| 8408 | cod_subroutine_declaration("short proc(short p1, unsigned short p2)", |
| 8409 | context); |
| 8410 | gen_code = cod_code_gen(code, context); |
| 8411 | proc = (short (*)(short, unsigned short))(long)gen_code->func; |
| 8412 | |
| 8413 | |
| 8414 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 8415 | short source1_s = src1s_vals[i]; |
| 8416 | for (j=0 ; j < sizeof(src2us_vals)/sizeof(src2us_vals[0]) ; j++) { |
| 8417 | unsigned short source2_us = src2us_vals[j]; |
| 8418 | |
| 8419 | short expected_result; |
| 8420 | short result; |
| 8421 | |
| 8422 | |
| 8423 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 8424 | |
| 8425 | expected_result = (short) (source1_s | source2_us); |
| 8426 | |
| 8427 | result = proc(source1_s, source2_us); |
| 8428 | if (expected_result != result) { |
| 8429 | printf("Failed short | unsigned short test, expected %d, got %d, for %d | %u\n", |
| 8430 | expected_result, result, source1_s, source2_us); |
| 8431 | if (dumped == 0) cod_dump(gen_code); |
| 8432 | failed++; |
| 8433 | dumped++; |
| 8434 | } |
| 8435 | } |
| 8436 | } |
| 8437 | if (verbose) printf(" done\n"); |
| 8438 | cod_free_parse_context(context); |
| 8439 | cod_code_free(gen_code); |
| 8440 | } |
| 8441 | if ((only_run_test == NULL((void*)0)) || |
| 8442 | (strcmp(only_run_test, "s|i") == 0)) { |
| 8443 | int i, j; |
| 8444 | static char code[] = "{\n\ |
| 8445 | short a = p1;\n\ |
| 8446 | int b = p2;\n\ |
| 8447 | return a | b;\n\ |
| 8448 | }"; |
| 8449 | |
| 8450 | short (*proc)(short a, int b); |
| 8451 | cod_parse_context context = new_cod_parse_context(); |
| 8452 | int dumped = 0; |
| 8453 | |
| 8454 | cod_code gen_code; |
| 8455 | |
| 8456 | /* test for short | int */ |
| 8457 | if (verbose) printf("test for short | int"); |
| 8458 | |
| 8459 | cod_assoc_externs(context, externs); |
| 8460 | cod_parse_for_context(extern_string, context); |
| 8461 | |
| 8462 | cod_subroutine_declaration("short proc(short p1, int p2)", |
| 8463 | context); |
| 8464 | gen_code = cod_code_gen(code, context); |
| 8465 | proc = (short (*)(short, int))(long)gen_code->func; |
| 8466 | |
| 8467 | |
| 8468 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 8469 | short source1_s = src1s_vals[i]; |
| 8470 | for (j=0 ; j < sizeof(src2i_vals)/sizeof(src2i_vals[0]) ; j++) { |
| 8471 | int source2_i = src2i_vals[j]; |
| 8472 | |
| 8473 | short expected_result; |
| 8474 | short result; |
| 8475 | |
| 8476 | |
| 8477 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 8478 | |
| 8479 | expected_result = (short) (source1_s | source2_i); |
| 8480 | |
| 8481 | result = proc(source1_s, source2_i); |
| 8482 | if (expected_result != result) { |
| 8483 | printf("Failed short | int test, expected %d, got %d, for %d | %d\n", |
| 8484 | expected_result, result, source1_s, source2_i); |
| 8485 | if (dumped == 0) cod_dump(gen_code); |
| 8486 | failed++; |
| 8487 | dumped++; |
| 8488 | } |
| 8489 | } |
| 8490 | } |
| 8491 | if (verbose) printf(" done\n"); |
| 8492 | cod_free_parse_context(context); |
| 8493 | cod_code_free(gen_code); |
| 8494 | } |
| 8495 | if ((only_run_test == NULL((void*)0)) || |
| 8496 | (strcmp(only_run_test, "s|u") == 0)) { |
| 8497 | int i, j; |
| 8498 | static char code[] = "{\n\ |
| 8499 | short a = p1;\n\ |
| 8500 | unsigned int b = p2;\n\ |
| 8501 | return a | b;\n\ |
| 8502 | }"; |
| 8503 | |
| 8504 | short (*proc)(short a, unsigned int b); |
| 8505 | cod_parse_context context = new_cod_parse_context(); |
| 8506 | int dumped = 0; |
| 8507 | |
| 8508 | cod_code gen_code; |
| 8509 | |
| 8510 | /* test for short | unsigned int */ |
| 8511 | if (verbose) printf("test for short | unsigned int"); |
| 8512 | |
| 8513 | cod_assoc_externs(context, externs); |
| 8514 | cod_parse_for_context(extern_string, context); |
| 8515 | |
| 8516 | cod_subroutine_declaration("short proc(short p1, unsigned int p2)", |
| 8517 | context); |
| 8518 | gen_code = cod_code_gen(code, context); |
| 8519 | proc = (short (*)(short, unsigned int))(long)gen_code->func; |
| 8520 | |
| 8521 | |
| 8522 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 8523 | short source1_s = src1s_vals[i]; |
| 8524 | for (j=0 ; j < sizeof(src2u_vals)/sizeof(src2u_vals[0]) ; j++) { |
| 8525 | unsigned int source2_u = src2u_vals[j]; |
| 8526 | |
| 8527 | short expected_result; |
| 8528 | short result; |
| 8529 | |
| 8530 | |
| 8531 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 8532 | |
| 8533 | expected_result = (short) (source1_s | source2_u); |
| 8534 | |
| 8535 | result = proc(source1_s, source2_u); |
| 8536 | if (expected_result != result) { |
| 8537 | printf("Failed short | unsigned int test, expected %d, got %d, for %d | %u\n", |
| 8538 | expected_result, result, source1_s, source2_u); |
| 8539 | if (dumped == 0) cod_dump(gen_code); |
| 8540 | failed++; |
| 8541 | dumped++; |
| 8542 | } |
| 8543 | } |
| 8544 | } |
| 8545 | if (verbose) printf(" done\n"); |
| 8546 | cod_free_parse_context(context); |
| 8547 | cod_code_free(gen_code); |
| 8548 | } |
| 8549 | if ((only_run_test == NULL((void*)0)) || |
| 8550 | (strcmp(only_run_test, "s|ul") == 0)) { |
| 8551 | int i, j; |
| 8552 | static char code[] = "{\n\ |
| 8553 | short a = p1;\n\ |
| 8554 | unsigned long b = p2;\n\ |
| 8555 | return a | b;\n\ |
| 8556 | }"; |
| 8557 | |
| 8558 | short (*proc)(short a, unsigned long b); |
| 8559 | cod_parse_context context = new_cod_parse_context(); |
| 8560 | int dumped = 0; |
| 8561 | |
| 8562 | cod_code gen_code; |
| 8563 | |
| 8564 | /* test for short | unsigned long */ |
| 8565 | if (verbose) printf("test for short | unsigned long"); |
| 8566 | |
| 8567 | cod_assoc_externs(context, externs); |
| 8568 | cod_parse_for_context(extern_string, context); |
| 8569 | |
| 8570 | cod_subroutine_declaration("short proc(short p1, unsigned long p2)", |
| 8571 | context); |
| 8572 | gen_code = cod_code_gen(code, context); |
| 8573 | proc = (short (*)(short, unsigned long))(long)gen_code->func; |
| 8574 | |
| 8575 | |
| 8576 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 8577 | short source1_s = src1s_vals[i]; |
| 8578 | for (j=0 ; j < sizeof(src2ul_vals)/sizeof(src2ul_vals[0]) ; j++) { |
| 8579 | unsigned long source2_ul = src2ul_vals[j]; |
| 8580 | |
| 8581 | short expected_result; |
| 8582 | short result; |
| 8583 | |
| 8584 | |
| 8585 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 8586 | |
| 8587 | expected_result = (short) (source1_s | source2_ul); |
| 8588 | |
| 8589 | result = proc(source1_s, source2_ul); |
| 8590 | if (expected_result != result) { |
| 8591 | printf("Failed short | unsigned long test, expected %d, got %d, for %d | %lu\n", |
| 8592 | expected_result, result, source1_s, source2_ul); |
| 8593 | if (dumped == 0) cod_dump(gen_code); |
| 8594 | failed++; |
| 8595 | dumped++; |
| 8596 | } |
| 8597 | } |
| 8598 | } |
| 8599 | if (verbose) printf(" done\n"); |
| 8600 | cod_free_parse_context(context); |
| 8601 | cod_code_free(gen_code); |
| 8602 | } |
| 8603 | if ((only_run_test == NULL((void*)0)) || |
| 8604 | (strcmp(only_run_test, "s|l") == 0)) { |
| 8605 | int i, j; |
| 8606 | static char code[] = "{\n\ |
| 8607 | short a = p1;\n\ |
| 8608 | long b = p2;\n\ |
| 8609 | return a | b;\n\ |
| 8610 | }"; |
| 8611 | |
| 8612 | short (*proc)(short a, long b); |
| 8613 | cod_parse_context context = new_cod_parse_context(); |
| 8614 | int dumped = 0; |
| 8615 | |
| 8616 | cod_code gen_code; |
| 8617 | |
| 8618 | /* test for short | long */ |
| 8619 | if (verbose) printf("test for short | long"); |
| 8620 | |
| 8621 | cod_assoc_externs(context, externs); |
| 8622 | cod_parse_for_context(extern_string, context); |
| 8623 | |
| 8624 | cod_subroutine_declaration("short proc(short p1, long p2)", |
| 8625 | context); |
| 8626 | gen_code = cod_code_gen(code, context); |
| 8627 | proc = (short (*)(short, long))(long)gen_code->func; |
| 8628 | |
| 8629 | |
| 8630 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 8631 | short source1_s = src1s_vals[i]; |
| 8632 | for (j=0 ; j < sizeof(src2l_vals)/sizeof(src2l_vals[0]) ; j++) { |
| 8633 | long source2_l = src2l_vals[j]; |
| 8634 | |
| 8635 | short expected_result; |
| 8636 | short result; |
| 8637 | |
| 8638 | |
| 8639 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 8640 | |
| 8641 | expected_result = (short) (source1_s | source2_l); |
| 8642 | |
| 8643 | result = proc(source1_s, source2_l); |
| 8644 | if (expected_result != result) { |
| 8645 | printf("Failed short | long test, expected %d, got %d, for %d | %ld\n", |
| 8646 | expected_result, result, source1_s, source2_l); |
| 8647 | if (dumped == 0) cod_dump(gen_code); |
| 8648 | failed++; |
| 8649 | dumped++; |
| 8650 | } |
| 8651 | } |
| 8652 | } |
| 8653 | if (verbose) printf(" done\n"); |
| 8654 | cod_free_parse_context(context); |
| 8655 | cod_code_free(gen_code); |
| 8656 | } |
| 8657 | } |
| 8658 | void or_us_tests() |
| 8659 | { |
| 8660 | if ((only_run_test == NULL((void*)0)) || |
| 8661 | (strcmp(only_run_test, "us|c") == 0)) { |
| 8662 | int i, j; |
| 8663 | static char code[] = "{\n\ |
| 8664 | unsigned short a = p1;\n\ |
| 8665 | signed char b = p2;\n\ |
| 8666 | return a | b;\n\ |
| 8667 | }"; |
| 8668 | |
| 8669 | unsigned short (*proc)(unsigned short a, signed char b); |
| 8670 | cod_parse_context context = new_cod_parse_context(); |
| 8671 | int dumped = 0; |
| 8672 | |
| 8673 | cod_code gen_code; |
| 8674 | |
| 8675 | /* test for unsigned short | signed char */ |
| 8676 | if (verbose) printf("test for unsigned short | signed char"); |
| 8677 | |
| 8678 | cod_assoc_externs(context, externs); |
| 8679 | cod_parse_for_context(extern_string, context); |
| 8680 | |
| 8681 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, signed char p2)", |
| 8682 | context); |
| 8683 | gen_code = cod_code_gen(code, context); |
| 8684 | proc = (unsigned short (*)(unsigned short, signed char))(long)gen_code->func; |
| 8685 | |
| 8686 | |
| 8687 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 8688 | unsigned short source1_us = src1us_vals[i]; |
| 8689 | for (j=0 ; j < sizeof(src2c_vals)/sizeof(src2c_vals[0]) ; j++) { |
| 8690 | signed char source2_c = src2c_vals[j]; |
| 8691 | |
| 8692 | unsigned short expected_result; |
| 8693 | unsigned short result; |
| 8694 | |
| 8695 | |
| 8696 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 8697 | |
| 8698 | expected_result = (unsigned short) (source1_us | source2_c); |
| 8699 | |
| 8700 | result = proc(source1_us, source2_c); |
| 8701 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 8702 | if (expected_result != result) { |
| 8703 | printf("Failed unsigned short | signed char test, expected %u, got %u, for %u | %d\n", |
| 8704 | expected_result, result, source1_us, source2_c); |
| 8705 | if (dumped == 0) cod_dump(gen_code); |
| 8706 | failed++; |
| 8707 | dumped++; |
| 8708 | } |
| 8709 | } |
| 8710 | } |
| 8711 | if (verbose) printf(" done\n"); |
| 8712 | cod_free_parse_context(context); |
| 8713 | cod_code_free(gen_code); |
| 8714 | } |
| 8715 | if ((only_run_test == NULL((void*)0)) || |
| 8716 | (strcmp(only_run_test, "us|uc") == 0)) { |
| 8717 | int i, j; |
| 8718 | static char code[] = "{\n\ |
| 8719 | unsigned short a = p1;\n\ |
| 8720 | unsigned char b = p2;\n\ |
| 8721 | return a | b;\n\ |
| 8722 | }"; |
| 8723 | |
| 8724 | unsigned short (*proc)(unsigned short a, unsigned char b); |
| 8725 | cod_parse_context context = new_cod_parse_context(); |
| 8726 | int dumped = 0; |
| 8727 | |
| 8728 | cod_code gen_code; |
| 8729 | |
| 8730 | /* test for unsigned short | unsigned char */ |
| 8731 | if (verbose) printf("test for unsigned short | unsigned char"); |
| 8732 | |
| 8733 | cod_assoc_externs(context, externs); |
| 8734 | cod_parse_for_context(extern_string, context); |
| 8735 | |
| 8736 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, unsigned char p2)", |
| 8737 | context); |
| 8738 | gen_code = cod_code_gen(code, context); |
| 8739 | proc = (unsigned short (*)(unsigned short, unsigned char))(long)gen_code->func; |
| 8740 | |
| 8741 | |
| 8742 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 8743 | unsigned short source1_us = src1us_vals[i]; |
| 8744 | for (j=0 ; j < sizeof(src2uc_vals)/sizeof(src2uc_vals[0]) ; j++) { |
| 8745 | unsigned char source2_uc = src2uc_vals[j]; |
| 8746 | |
| 8747 | unsigned short expected_result; |
| 8748 | unsigned short result; |
| 8749 | |
| 8750 | |
| 8751 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 8752 | |
| 8753 | expected_result = (unsigned short) (source1_us | source2_uc); |
| 8754 | |
| 8755 | result = proc(source1_us, source2_uc); |
| 8756 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 8757 | if (expected_result != result) { |
| 8758 | printf("Failed unsigned short | unsigned char test, expected %u, got %u, for %u | %u\n", |
| 8759 | expected_result, result, source1_us, source2_uc); |
| 8760 | if (dumped == 0) cod_dump(gen_code); |
| 8761 | failed++; |
| 8762 | dumped++; |
| 8763 | } |
| 8764 | } |
| 8765 | } |
| 8766 | if (verbose) printf(" done\n"); |
| 8767 | cod_free_parse_context(context); |
| 8768 | cod_code_free(gen_code); |
| 8769 | } |
| 8770 | if ((only_run_test == NULL((void*)0)) || |
| 8771 | (strcmp(only_run_test, "us|s") == 0)) { |
| 8772 | int i, j; |
| 8773 | static char code[] = "{\n\ |
| 8774 | unsigned short a = p1;\n\ |
| 8775 | short b = p2;\n\ |
| 8776 | return a | b;\n\ |
| 8777 | }"; |
| 8778 | |
| 8779 | unsigned short (*proc)(unsigned short a, short b); |
| 8780 | cod_parse_context context = new_cod_parse_context(); |
| 8781 | int dumped = 0; |
| 8782 | |
| 8783 | cod_code gen_code; |
| 8784 | |
| 8785 | /* test for unsigned short | short */ |
| 8786 | if (verbose) printf("test for unsigned short | short"); |
| 8787 | |
| 8788 | cod_assoc_externs(context, externs); |
| 8789 | cod_parse_for_context(extern_string, context); |
| 8790 | |
| 8791 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, short p2)", |
| 8792 | context); |
| 8793 | gen_code = cod_code_gen(code, context); |
| 8794 | proc = (unsigned short (*)(unsigned short, short))(long)gen_code->func; |
| 8795 | |
| 8796 | |
| 8797 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 8798 | unsigned short source1_us = src1us_vals[i]; |
| 8799 | for (j=0 ; j < sizeof(src2s_vals)/sizeof(src2s_vals[0]) ; j++) { |
| 8800 | short source2_s = src2s_vals[j]; |
| 8801 | |
| 8802 | unsigned short expected_result; |
| 8803 | unsigned short result; |
| 8804 | |
| 8805 | |
| 8806 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 8807 | |
| 8808 | expected_result = (unsigned short) (source1_us | source2_s); |
| 8809 | |
| 8810 | result = proc(source1_us, source2_s); |
| 8811 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 8812 | if (expected_result != result) { |
| 8813 | printf("Failed unsigned short | short test, expected %u, got %u, for %u | %d\n", |
| 8814 | expected_result, result, source1_us, source2_s); |
| 8815 | if (dumped == 0) cod_dump(gen_code); |
| 8816 | failed++; |
| 8817 | dumped++; |
| 8818 | } |
| 8819 | } |
| 8820 | } |
| 8821 | if (verbose) printf(" done\n"); |
| 8822 | cod_free_parse_context(context); |
| 8823 | cod_code_free(gen_code); |
| 8824 | } |
| 8825 | if ((only_run_test == NULL((void*)0)) || |
| 8826 | (strcmp(only_run_test, "us|us") == 0)) { |
| 8827 | int i, j; |
| 8828 | static char code[] = "{\n\ |
| 8829 | unsigned short a = p1;\n\ |
| 8830 | unsigned short b = p2;\n\ |
| 8831 | return a | b;\n\ |
| 8832 | }"; |
| 8833 | |
| 8834 | unsigned short (*proc)(unsigned short a, unsigned short b); |
| 8835 | cod_parse_context context = new_cod_parse_context(); |
| 8836 | int dumped = 0; |
| 8837 | |
| 8838 | cod_code gen_code; |
| 8839 | |
| 8840 | /* test for unsigned short | unsigned short */ |
| 8841 | if (verbose) printf("test for unsigned short | unsigned short"); |
| 8842 | |
| 8843 | cod_assoc_externs(context, externs); |
| 8844 | cod_parse_for_context(extern_string, context); |
| 8845 | |
| 8846 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, unsigned short p2)", |
| 8847 | context); |
| 8848 | gen_code = cod_code_gen(code, context); |
| 8849 | proc = (unsigned short (*)(unsigned short, unsigned short))(long)gen_code->func; |
| 8850 | |
| 8851 | |
| 8852 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 8853 | unsigned short source1_us = src1us_vals[i]; |
| 8854 | for (j=0 ; j < sizeof(src2us_vals)/sizeof(src2us_vals[0]) ; j++) { |
| 8855 | unsigned short source2_us = src2us_vals[j]; |
| 8856 | |
| 8857 | unsigned short expected_result; |
| 8858 | unsigned short result; |
| 8859 | |
| 8860 | |
| 8861 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 8862 | |
| 8863 | expected_result = (unsigned short) (source1_us | source2_us); |
| 8864 | |
| 8865 | result = proc(source1_us, source2_us); |
| 8866 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 8867 | if (expected_result != result) { |
| 8868 | printf("Failed unsigned short | unsigned short test, expected %u, got %u, for %u | %u\n", |
| 8869 | expected_result, result, source1_us, source2_us); |
| 8870 | if (dumped == 0) cod_dump(gen_code); |
| 8871 | failed++; |
| 8872 | dumped++; |
| 8873 | } |
| 8874 | } |
| 8875 | } |
| 8876 | if (verbose) printf(" done\n"); |
| 8877 | cod_free_parse_context(context); |
| 8878 | cod_code_free(gen_code); |
| 8879 | } |
| 8880 | if ((only_run_test == NULL((void*)0)) || |
| 8881 | (strcmp(only_run_test, "us|i") == 0)) { |
| 8882 | int i, j; |
| 8883 | static char code[] = "{\n\ |
| 8884 | unsigned short a = p1;\n\ |
| 8885 | int b = p2;\n\ |
| 8886 | return a | b;\n\ |
| 8887 | }"; |
| 8888 | |
| 8889 | unsigned short (*proc)(unsigned short a, int b); |
| 8890 | cod_parse_context context = new_cod_parse_context(); |
| 8891 | int dumped = 0; |
| 8892 | |
| 8893 | cod_code gen_code; |
| 8894 | |
| 8895 | /* test for unsigned short | int */ |
| 8896 | if (verbose) printf("test for unsigned short | int"); |
| 8897 | |
| 8898 | cod_assoc_externs(context, externs); |
| 8899 | cod_parse_for_context(extern_string, context); |
| 8900 | |
| 8901 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, int p2)", |
| 8902 | context); |
| 8903 | gen_code = cod_code_gen(code, context); |
| 8904 | proc = (unsigned short (*)(unsigned short, int))(long)gen_code->func; |
| 8905 | |
| 8906 | |
| 8907 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 8908 | unsigned short source1_us = src1us_vals[i]; |
| 8909 | for (j=0 ; j < sizeof(src2i_vals)/sizeof(src2i_vals[0]) ; j++) { |
| 8910 | int source2_i = src2i_vals[j]; |
| 8911 | |
| 8912 | unsigned short expected_result; |
| 8913 | unsigned short result; |
| 8914 | |
| 8915 | |
| 8916 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 8917 | |
| 8918 | expected_result = (unsigned short) (source1_us | source2_i); |
| 8919 | |
| 8920 | result = proc(source1_us, source2_i); |
| 8921 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 8922 | if (expected_result != result) { |
| 8923 | printf("Failed unsigned short | int test, expected %u, got %u, for %u | %d\n", |
| 8924 | expected_result, result, source1_us, source2_i); |
| 8925 | if (dumped == 0) cod_dump(gen_code); |
| 8926 | failed++; |
| 8927 | dumped++; |
| 8928 | } |
| 8929 | } |
| 8930 | } |
| 8931 | if (verbose) printf(" done\n"); |
| 8932 | cod_free_parse_context(context); |
| 8933 | cod_code_free(gen_code); |
| 8934 | } |
| 8935 | if ((only_run_test == NULL((void*)0)) || |
| 8936 | (strcmp(only_run_test, "us|u") == 0)) { |
| 8937 | int i, j; |
| 8938 | static char code[] = "{\n\ |
| 8939 | unsigned short a = p1;\n\ |
| 8940 | unsigned int b = p2;\n\ |
| 8941 | return a | b;\n\ |
| 8942 | }"; |
| 8943 | |
| 8944 | unsigned short (*proc)(unsigned short a, unsigned int b); |
| 8945 | cod_parse_context context = new_cod_parse_context(); |
| 8946 | int dumped = 0; |
| 8947 | |
| 8948 | cod_code gen_code; |
| 8949 | |
| 8950 | /* test for unsigned short | unsigned int */ |
| 8951 | if (verbose) printf("test for unsigned short | unsigned int"); |
| 8952 | |
| 8953 | cod_assoc_externs(context, externs); |
| 8954 | cod_parse_for_context(extern_string, context); |
| 8955 | |
| 8956 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, unsigned int p2)", |
| 8957 | context); |
| 8958 | gen_code = cod_code_gen(code, context); |
| 8959 | proc = (unsigned short (*)(unsigned short, unsigned int))(long)gen_code->func; |
| 8960 | |
| 8961 | |
| 8962 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 8963 | unsigned short source1_us = src1us_vals[i]; |
| 8964 | for (j=0 ; j < sizeof(src2u_vals)/sizeof(src2u_vals[0]) ; j++) { |
| 8965 | unsigned int source2_u = src2u_vals[j]; |
| 8966 | |
| 8967 | unsigned short expected_result; |
| 8968 | unsigned short result; |
| 8969 | |
| 8970 | |
| 8971 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 8972 | |
| 8973 | expected_result = (unsigned short) (source1_us | source2_u); |
| 8974 | |
| 8975 | result = proc(source1_us, source2_u); |
| 8976 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 8977 | if (expected_result != result) { |
| 8978 | printf("Failed unsigned short | unsigned int test, expected %u, got %u, for %u | %u\n", |
| 8979 | expected_result, result, source1_us, source2_u); |
| 8980 | if (dumped == 0) cod_dump(gen_code); |
| 8981 | failed++; |
| 8982 | dumped++; |
| 8983 | } |
| 8984 | } |
| 8985 | } |
| 8986 | if (verbose) printf(" done\n"); |
| 8987 | cod_free_parse_context(context); |
| 8988 | cod_code_free(gen_code); |
| 8989 | } |
| 8990 | if ((only_run_test == NULL((void*)0)) || |
| 8991 | (strcmp(only_run_test, "us|ul") == 0)) { |
| 8992 | int i, j; |
| 8993 | static char code[] = "{\n\ |
| 8994 | unsigned short a = p1;\n\ |
| 8995 | unsigned long b = p2;\n\ |
| 8996 | return a | b;\n\ |
| 8997 | }"; |
| 8998 | |
| 8999 | unsigned short (*proc)(unsigned short a, unsigned long b); |
| 9000 | cod_parse_context context = new_cod_parse_context(); |
| 9001 | int dumped = 0; |
| 9002 | |
| 9003 | cod_code gen_code; |
| 9004 | |
| 9005 | /* test for unsigned short | unsigned long */ |
| 9006 | if (verbose) printf("test for unsigned short | unsigned long"); |
| 9007 | |
| 9008 | cod_assoc_externs(context, externs); |
| 9009 | cod_parse_for_context(extern_string, context); |
| 9010 | |
| 9011 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, unsigned long p2)", |
| 9012 | context); |
| 9013 | gen_code = cod_code_gen(code, context); |
| 9014 | proc = (unsigned short (*)(unsigned short, unsigned long))(long)gen_code->func; |
| 9015 | |
| 9016 | |
| 9017 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 9018 | unsigned short source1_us = src1us_vals[i]; |
| 9019 | for (j=0 ; j < sizeof(src2ul_vals)/sizeof(src2ul_vals[0]) ; j++) { |
| 9020 | unsigned long source2_ul = src2ul_vals[j]; |
| 9021 | |
| 9022 | unsigned short expected_result; |
| 9023 | unsigned short result; |
| 9024 | |
| 9025 | |
| 9026 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 9027 | |
| 9028 | expected_result = (unsigned short) (source1_us | source2_ul); |
| 9029 | |
| 9030 | result = proc(source1_us, source2_ul); |
| 9031 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 9032 | if (expected_result != result) { |
| 9033 | printf("Failed unsigned short | unsigned long test, expected %u, got %u, for %u | %lu\n", |
| 9034 | expected_result, result, source1_us, source2_ul); |
| 9035 | if (dumped == 0) cod_dump(gen_code); |
| 9036 | failed++; |
| 9037 | dumped++; |
| 9038 | } |
| 9039 | } |
| 9040 | } |
| 9041 | if (verbose) printf(" done\n"); |
| 9042 | cod_free_parse_context(context); |
| 9043 | cod_code_free(gen_code); |
| 9044 | } |
| 9045 | if ((only_run_test == NULL((void*)0)) || |
| 9046 | (strcmp(only_run_test, "us|l") == 0)) { |
| 9047 | int i, j; |
| 9048 | static char code[] = "{\n\ |
| 9049 | unsigned short a = p1;\n\ |
| 9050 | long b = p2;\n\ |
| 9051 | return a | b;\n\ |
| 9052 | }"; |
| 9053 | |
| 9054 | unsigned short (*proc)(unsigned short a, long b); |
| 9055 | cod_parse_context context = new_cod_parse_context(); |
| 9056 | int dumped = 0; |
| 9057 | |
| 9058 | cod_code gen_code; |
| 9059 | |
| 9060 | /* test for unsigned short | long */ |
| 9061 | if (verbose) printf("test for unsigned short | long"); |
| 9062 | |
| 9063 | cod_assoc_externs(context, externs); |
| 9064 | cod_parse_for_context(extern_string, context); |
| 9065 | |
| 9066 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, long p2)", |
| 9067 | context); |
| 9068 | gen_code = cod_code_gen(code, context); |
| 9069 | proc = (unsigned short (*)(unsigned short, long))(long)gen_code->func; |
| 9070 | |
| 9071 | |
| 9072 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 9073 | unsigned short source1_us = src1us_vals[i]; |
| 9074 | for (j=0 ; j < sizeof(src2l_vals)/sizeof(src2l_vals[0]) ; j++) { |
| 9075 | long source2_l = src2l_vals[j]; |
| 9076 | |
| 9077 | unsigned short expected_result; |
| 9078 | unsigned short result; |
| 9079 | |
| 9080 | |
| 9081 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 9082 | |
| 9083 | expected_result = (unsigned short) (source1_us | source2_l); |
| 9084 | |
| 9085 | result = proc(source1_us, source2_l); |
| 9086 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 9087 | if (expected_result != result) { |
| 9088 | printf("Failed unsigned short | long test, expected %u, got %u, for %u | %ld\n", |
| 9089 | expected_result, result, source1_us, source2_l); |
| 9090 | if (dumped == 0) cod_dump(gen_code); |
| 9091 | failed++; |
| 9092 | dumped++; |
| 9093 | } |
| 9094 | } |
| 9095 | } |
| 9096 | if (verbose) printf(" done\n"); |
| 9097 | cod_free_parse_context(context); |
| 9098 | cod_code_free(gen_code); |
| 9099 | } |
| 9100 | } |
| 9101 | void or_i_tests() |
| 9102 | { |
| 9103 | if ((only_run_test == NULL((void*)0)) || |
| 9104 | (strcmp(only_run_test, "i|c") == 0)) { |
| 9105 | int i, j; |
| 9106 | static char code[] = "{\n\ |
| 9107 | int a = p1;\n\ |
| 9108 | signed char b = p2;\n\ |
| 9109 | return a | b;\n\ |
| 9110 | }"; |
| 9111 | |
| 9112 | int (*proc)(int a, signed char b); |
| 9113 | cod_parse_context context = new_cod_parse_context(); |
| 9114 | int dumped = 0; |
| 9115 | |
| 9116 | cod_code gen_code; |
| 9117 | |
| 9118 | /* test for int | signed char */ |
| 9119 | if (verbose) printf("test for int | signed char"); |
| 9120 | |
| 9121 | cod_assoc_externs(context, externs); |
| 9122 | cod_parse_for_context(extern_string, context); |
| 9123 | |
| 9124 | cod_subroutine_declaration("int proc(int p1, signed char p2)", |
| 9125 | context); |
| 9126 | gen_code = cod_code_gen(code, context); |
| 9127 | proc = (int (*)(int, signed char))(long)gen_code->func; |
| 9128 | |
| 9129 | |
| 9130 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 9131 | int source1_i = src1i_vals[i]; |
| 9132 | for (j=0 ; j < sizeof(src2c_vals)/sizeof(src2c_vals[0]) ; j++) { |
| 9133 | signed char source2_c = src2c_vals[j]; |
| 9134 | |
| 9135 | int expected_result; |
| 9136 | int result; |
| 9137 | |
| 9138 | |
| 9139 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 9140 | |
| 9141 | expected_result = (int) (source1_i | source2_c); |
| 9142 | |
| 9143 | result = proc(source1_i, source2_c); |
| 9144 | if (expected_result != result) { |
| 9145 | printf("Failed int | signed char test, expected %d, got %d, for %d | %d\n", |
| 9146 | expected_result, result, source1_i, source2_c); |
| 9147 | if (dumped == 0) cod_dump(gen_code); |
| 9148 | failed++; |
| 9149 | dumped++; |
| 9150 | } |
| 9151 | } |
| 9152 | } |
| 9153 | if (verbose) printf(" done\n"); |
| 9154 | cod_free_parse_context(context); |
| 9155 | cod_code_free(gen_code); |
| 9156 | } |
| 9157 | if ((only_run_test == NULL((void*)0)) || |
| 9158 | (strcmp(only_run_test, "i|uc") == 0)) { |
| 9159 | int i, j; |
| 9160 | static char code[] = "{\n\ |
| 9161 | int a = p1;\n\ |
| 9162 | unsigned char b = p2;\n\ |
| 9163 | return a | b;\n\ |
| 9164 | }"; |
| 9165 | |
| 9166 | int (*proc)(int a, unsigned char b); |
| 9167 | cod_parse_context context = new_cod_parse_context(); |
| 9168 | int dumped = 0; |
| 9169 | |
| 9170 | cod_code gen_code; |
| 9171 | |
| 9172 | /* test for int | unsigned char */ |
| 9173 | if (verbose) printf("test for int | unsigned char"); |
| 9174 | |
| 9175 | cod_assoc_externs(context, externs); |
| 9176 | cod_parse_for_context(extern_string, context); |
| 9177 | |
| 9178 | cod_subroutine_declaration("int proc(int p1, unsigned char p2)", |
| 9179 | context); |
| 9180 | gen_code = cod_code_gen(code, context); |
| 9181 | proc = (int (*)(int, unsigned char))(long)gen_code->func; |
| 9182 | |
| 9183 | |
| 9184 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 9185 | int source1_i = src1i_vals[i]; |
| 9186 | for (j=0 ; j < sizeof(src2uc_vals)/sizeof(src2uc_vals[0]) ; j++) { |
| 9187 | unsigned char source2_uc = src2uc_vals[j]; |
| 9188 | |
| 9189 | int expected_result; |
| 9190 | int result; |
| 9191 | |
| 9192 | |
| 9193 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 9194 | |
| 9195 | expected_result = (int) (source1_i | source2_uc); |
| 9196 | |
| 9197 | result = proc(source1_i, source2_uc); |
| 9198 | if (expected_result != result) { |
| 9199 | printf("Failed int | unsigned char test, expected %d, got %d, for %d | %u\n", |
| 9200 | expected_result, result, source1_i, source2_uc); |
| 9201 | if (dumped == 0) cod_dump(gen_code); |
| 9202 | failed++; |
| 9203 | dumped++; |
| 9204 | } |
| 9205 | } |
| 9206 | } |
| 9207 | if (verbose) printf(" done\n"); |
| 9208 | cod_free_parse_context(context); |
| 9209 | cod_code_free(gen_code); |
| 9210 | } |
| 9211 | if ((only_run_test == NULL((void*)0)) || |
| 9212 | (strcmp(only_run_test, "i|s") == 0)) { |
| 9213 | int i, j; |
| 9214 | static char code[] = "{\n\ |
| 9215 | int a = p1;\n\ |
| 9216 | short b = p2;\n\ |
| 9217 | return a | b;\n\ |
| 9218 | }"; |
| 9219 | |
| 9220 | int (*proc)(int a, short b); |
| 9221 | cod_parse_context context = new_cod_parse_context(); |
| 9222 | int dumped = 0; |
| 9223 | |
| 9224 | cod_code gen_code; |
| 9225 | |
| 9226 | /* test for int | short */ |
| 9227 | if (verbose) printf("test for int | short"); |
| 9228 | |
| 9229 | cod_assoc_externs(context, externs); |
| 9230 | cod_parse_for_context(extern_string, context); |
| 9231 | |
| 9232 | cod_subroutine_declaration("int proc(int p1, short p2)", |
| 9233 | context); |
| 9234 | gen_code = cod_code_gen(code, context); |
| 9235 | proc = (int (*)(int, short))(long)gen_code->func; |
| 9236 | |
| 9237 | |
| 9238 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 9239 | int source1_i = src1i_vals[i]; |
| 9240 | for (j=0 ; j < sizeof(src2s_vals)/sizeof(src2s_vals[0]) ; j++) { |
| 9241 | short source2_s = src2s_vals[j]; |
| 9242 | |
| 9243 | int expected_result; |
| 9244 | int result; |
| 9245 | |
| 9246 | |
| 9247 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 9248 | |
| 9249 | expected_result = (int) (source1_i | source2_s); |
| 9250 | |
| 9251 | result = proc(source1_i, source2_s); |
| 9252 | if (expected_result != result) { |
| 9253 | printf("Failed int | short test, expected %d, got %d, for %d | %d\n", |
| 9254 | expected_result, result, source1_i, source2_s); |
| 9255 | if (dumped == 0) cod_dump(gen_code); |
| 9256 | failed++; |
| 9257 | dumped++; |
| 9258 | } |
| 9259 | } |
| 9260 | } |
| 9261 | if (verbose) printf(" done\n"); |
| 9262 | cod_free_parse_context(context); |
| 9263 | cod_code_free(gen_code); |
| 9264 | } |
| 9265 | if ((only_run_test == NULL((void*)0)) || |
| 9266 | (strcmp(only_run_test, "i|us") == 0)) { |
| 9267 | int i, j; |
| 9268 | static char code[] = "{\n\ |
| 9269 | int a = p1;\n\ |
| 9270 | unsigned short b = p2;\n\ |
| 9271 | return a | b;\n\ |
| 9272 | }"; |
| 9273 | |
| 9274 | int (*proc)(int a, unsigned short b); |
| 9275 | cod_parse_context context = new_cod_parse_context(); |
| 9276 | int dumped = 0; |
| 9277 | |
| 9278 | cod_code gen_code; |
| 9279 | |
| 9280 | /* test for int | unsigned short */ |
| 9281 | if (verbose) printf("test for int | unsigned short"); |
| 9282 | |
| 9283 | cod_assoc_externs(context, externs); |
| 9284 | cod_parse_for_context(extern_string, context); |
| 9285 | |
| 9286 | cod_subroutine_declaration("int proc(int p1, unsigned short p2)", |
| 9287 | context); |
| 9288 | gen_code = cod_code_gen(code, context); |
| 9289 | proc = (int (*)(int, unsigned short))(long)gen_code->func; |
| 9290 | |
| 9291 | |
| 9292 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 9293 | int source1_i = src1i_vals[i]; |
| 9294 | for (j=0 ; j < sizeof(src2us_vals)/sizeof(src2us_vals[0]) ; j++) { |
| 9295 | unsigned short source2_us = src2us_vals[j]; |
| 9296 | |
| 9297 | int expected_result; |
| 9298 | int result; |
| 9299 | |
| 9300 | |
| 9301 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 9302 | |
| 9303 | expected_result = (int) (source1_i | source2_us); |
| 9304 | |
| 9305 | result = proc(source1_i, source2_us); |
| 9306 | if (expected_result != result) { |
| 9307 | printf("Failed int | unsigned short test, expected %d, got %d, for %d | %u\n", |
| 9308 | expected_result, result, source1_i, source2_us); |
| 9309 | if (dumped == 0) cod_dump(gen_code); |
| 9310 | failed++; |
| 9311 | dumped++; |
| 9312 | } |
| 9313 | } |
| 9314 | } |
| 9315 | if (verbose) printf(" done\n"); |
| 9316 | cod_free_parse_context(context); |
| 9317 | cod_code_free(gen_code); |
| 9318 | } |
| 9319 | if ((only_run_test == NULL((void*)0)) || |
| 9320 | (strcmp(only_run_test, "i|i") == 0)) { |
| 9321 | int i, j; |
| 9322 | static char code[] = "{\n\ |
| 9323 | int a = p1;\n\ |
| 9324 | int b = p2;\n\ |
| 9325 | return a | b;\n\ |
| 9326 | }"; |
| 9327 | |
| 9328 | int (*proc)(int a, int b); |
| 9329 | cod_parse_context context = new_cod_parse_context(); |
| 9330 | int dumped = 0; |
| 9331 | |
| 9332 | cod_code gen_code; |
| 9333 | |
| 9334 | /* test for int | int */ |
| 9335 | if (verbose) printf("test for int | int"); |
| 9336 | |
| 9337 | cod_assoc_externs(context, externs); |
| 9338 | cod_parse_for_context(extern_string, context); |
| 9339 | |
| 9340 | cod_subroutine_declaration("int proc(int p1, int p2)", |
| 9341 | context); |
| 9342 | gen_code = cod_code_gen(code, context); |
| 9343 | proc = (int (*)(int, int))(long)gen_code->func; |
| 9344 | |
| 9345 | |
| 9346 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 9347 | int source1_i = src1i_vals[i]; |
| 9348 | for (j=0 ; j < sizeof(src2i_vals)/sizeof(src2i_vals[0]) ; j++) { |
| 9349 | int source2_i = src2i_vals[j]; |
| 9350 | |
| 9351 | int expected_result; |
| 9352 | int result; |
| 9353 | |
| 9354 | |
| 9355 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 9356 | |
| 9357 | expected_result = (int) (source1_i | source2_i); |
| 9358 | |
| 9359 | result = proc(source1_i, source2_i); |
| 9360 | if (expected_result != result) { |
| 9361 | printf("Failed int | int test, expected %d, got %d, for %d | %d\n", |
| 9362 | expected_result, result, source1_i, source2_i); |
| 9363 | if (dumped == 0) cod_dump(gen_code); |
| 9364 | failed++; |
| 9365 | dumped++; |
| 9366 | } |
| 9367 | } |
| 9368 | } |
| 9369 | if (verbose) printf(" done\n"); |
| 9370 | cod_free_parse_context(context); |
| 9371 | cod_code_free(gen_code); |
| 9372 | } |
| 9373 | if ((only_run_test == NULL((void*)0)) || |
| 9374 | (strcmp(only_run_test, "i|u") == 0)) { |
| 9375 | int i, j; |
| 9376 | static char code[] = "{\n\ |
| 9377 | int a = p1;\n\ |
| 9378 | unsigned int b = p2;\n\ |
| 9379 | return a | b;\n\ |
| 9380 | }"; |
| 9381 | |
| 9382 | int (*proc)(int a, unsigned int b); |
| 9383 | cod_parse_context context = new_cod_parse_context(); |
| 9384 | int dumped = 0; |
| 9385 | |
| 9386 | cod_code gen_code; |
| 9387 | |
| 9388 | /* test for int | unsigned int */ |
| 9389 | if (verbose) printf("test for int | unsigned int"); |
| 9390 | |
| 9391 | cod_assoc_externs(context, externs); |
| 9392 | cod_parse_for_context(extern_string, context); |
| 9393 | |
| 9394 | cod_subroutine_declaration("int proc(int p1, unsigned int p2)", |
| 9395 | context); |
| 9396 | gen_code = cod_code_gen(code, context); |
| 9397 | proc = (int (*)(int, unsigned int))(long)gen_code->func; |
| 9398 | |
| 9399 | |
| 9400 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 9401 | int source1_i = src1i_vals[i]; |
| 9402 | for (j=0 ; j < sizeof(src2u_vals)/sizeof(src2u_vals[0]) ; j++) { |
| 9403 | unsigned int source2_u = src2u_vals[j]; |
| 9404 | |
| 9405 | int expected_result; |
| 9406 | int result; |
| 9407 | |
| 9408 | |
| 9409 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 9410 | |
| 9411 | expected_result = (int) (source1_i | source2_u); |
| 9412 | |
| 9413 | result = proc(source1_i, source2_u); |
| 9414 | if (expected_result != result) { |
| 9415 | printf("Failed int | unsigned int test, expected %d, got %d, for %d | %u\n", |
| 9416 | expected_result, result, source1_i, source2_u); |
| 9417 | if (dumped == 0) cod_dump(gen_code); |
| 9418 | failed++; |
| 9419 | dumped++; |
| 9420 | } |
| 9421 | } |
| 9422 | } |
| 9423 | if (verbose) printf(" done\n"); |
| 9424 | cod_free_parse_context(context); |
| 9425 | cod_code_free(gen_code); |
| 9426 | } |
| 9427 | if ((only_run_test == NULL((void*)0)) || |
| 9428 | (strcmp(only_run_test, "i|ul") == 0)) { |
| 9429 | int i, j; |
| 9430 | static char code[] = "{\n\ |
| 9431 | int a = p1;\n\ |
| 9432 | unsigned long b = p2;\n\ |
| 9433 | return a | b;\n\ |
| 9434 | }"; |
| 9435 | |
| 9436 | int (*proc)(int a, unsigned long b); |
| 9437 | cod_parse_context context = new_cod_parse_context(); |
| 9438 | int dumped = 0; |
| 9439 | |
| 9440 | cod_code gen_code; |
| 9441 | |
| 9442 | /* test for int | unsigned long */ |
| 9443 | if (verbose) printf("test for int | unsigned long"); |
| 9444 | |
| 9445 | cod_assoc_externs(context, externs); |
| 9446 | cod_parse_for_context(extern_string, context); |
| 9447 | |
| 9448 | cod_subroutine_declaration("int proc(int p1, unsigned long p2)", |
| 9449 | context); |
| 9450 | gen_code = cod_code_gen(code, context); |
| 9451 | proc = (int (*)(int, unsigned long))(long)gen_code->func; |
| 9452 | |
| 9453 | |
| 9454 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 9455 | int source1_i = src1i_vals[i]; |
| 9456 | for (j=0 ; j < sizeof(src2ul_vals)/sizeof(src2ul_vals[0]) ; j++) { |
| 9457 | unsigned long source2_ul = src2ul_vals[j]; |
| 9458 | |
| 9459 | int expected_result; |
| 9460 | int result; |
| 9461 | |
| 9462 | |
| 9463 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 9464 | |
| 9465 | expected_result = (int) (source1_i | source2_ul); |
| 9466 | |
| 9467 | result = proc(source1_i, source2_ul); |
| 9468 | if (expected_result != result) { |
| 9469 | printf("Failed int | unsigned long test, expected %d, got %d, for %d | %lu\n", |
| 9470 | expected_result, result, source1_i, source2_ul); |
| 9471 | if (dumped == 0) cod_dump(gen_code); |
| 9472 | failed++; |
| 9473 | dumped++; |
| 9474 | } |
| 9475 | } |
| 9476 | } |
| 9477 | if (verbose) printf(" done\n"); |
| 9478 | cod_free_parse_context(context); |
| 9479 | cod_code_free(gen_code); |
| 9480 | } |
| 9481 | if ((only_run_test == NULL((void*)0)) || |
| 9482 | (strcmp(only_run_test, "i|l") == 0)) { |
| 9483 | int i, j; |
| 9484 | static char code[] = "{\n\ |
| 9485 | int a = p1;\n\ |
| 9486 | long b = p2;\n\ |
| 9487 | return a | b;\n\ |
| 9488 | }"; |
| 9489 | |
| 9490 | int (*proc)(int a, long b); |
| 9491 | cod_parse_context context = new_cod_parse_context(); |
| 9492 | int dumped = 0; |
| 9493 | |
| 9494 | cod_code gen_code; |
| 9495 | |
| 9496 | /* test for int | long */ |
| 9497 | if (verbose) printf("test for int | long"); |
| 9498 | |
| 9499 | cod_assoc_externs(context, externs); |
| 9500 | cod_parse_for_context(extern_string, context); |
| 9501 | |
| 9502 | cod_subroutine_declaration("int proc(int p1, long p2)", |
| 9503 | context); |
| 9504 | gen_code = cod_code_gen(code, context); |
| 9505 | proc = (int (*)(int, long))(long)gen_code->func; |
| 9506 | |
| 9507 | |
| 9508 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 9509 | int source1_i = src1i_vals[i]; |
| 9510 | for (j=0 ; j < sizeof(src2l_vals)/sizeof(src2l_vals[0]) ; j++) { |
| 9511 | long source2_l = src2l_vals[j]; |
| 9512 | |
| 9513 | int expected_result; |
| 9514 | int result; |
| 9515 | |
| 9516 | |
| 9517 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 9518 | |
| 9519 | expected_result = (int) (source1_i | source2_l); |
| 9520 | |
| 9521 | result = proc(source1_i, source2_l); |
| 9522 | if (expected_result != result) { |
| 9523 | printf("Failed int | long test, expected %d, got %d, for %d | %ld\n", |
| 9524 | expected_result, result, source1_i, source2_l); |
| 9525 | if (dumped == 0) cod_dump(gen_code); |
| 9526 | failed++; |
| 9527 | dumped++; |
| 9528 | } |
| 9529 | } |
| 9530 | } |
| 9531 | if (verbose) printf(" done\n"); |
| 9532 | cod_free_parse_context(context); |
| 9533 | cod_code_free(gen_code); |
| 9534 | } |
| 9535 | } |
| 9536 | void or_u_tests() |
| 9537 | { |
| 9538 | if ((only_run_test == NULL((void*)0)) || |
| 9539 | (strcmp(only_run_test, "u|c") == 0)) { |
| 9540 | int i, j; |
| 9541 | static char code[] = "{\n\ |
| 9542 | unsigned int a = p1;\n\ |
| 9543 | signed char b = p2;\n\ |
| 9544 | return a | b;\n\ |
| 9545 | }"; |
| 9546 | |
| 9547 | unsigned int (*proc)(unsigned int a, signed char b); |
| 9548 | cod_parse_context context = new_cod_parse_context(); |
| 9549 | int dumped = 0; |
| 9550 | |
| 9551 | cod_code gen_code; |
| 9552 | |
| 9553 | /* test for unsigned int | signed char */ |
| 9554 | if (verbose) printf("test for unsigned int | signed char"); |
| 9555 | |
| 9556 | cod_assoc_externs(context, externs); |
| 9557 | cod_parse_for_context(extern_string, context); |
| 9558 | |
| 9559 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, signed char p2)", |
| 9560 | context); |
| 9561 | gen_code = cod_code_gen(code, context); |
| 9562 | proc = (unsigned int (*)(unsigned int, signed char))(long)gen_code->func; |
| 9563 | |
| 9564 | |
| 9565 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 9566 | unsigned int source1_u = src1u_vals[i]; |
| 9567 | for (j=0 ; j < sizeof(src2c_vals)/sizeof(src2c_vals[0]) ; j++) { |
| 9568 | signed char source2_c = src2c_vals[j]; |
| 9569 | |
| 9570 | unsigned int expected_result; |
| 9571 | unsigned int result; |
| 9572 | |
| 9573 | |
| 9574 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 9575 | |
| 9576 | expected_result = (unsigned int) (source1_u | source2_c); |
| 9577 | |
| 9578 | result = proc(source1_u, source2_c); |
| 9579 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 9580 | if (expected_result != result) { |
| 9581 | printf("Failed unsigned int | signed char test, expected %u, got %u, for %u | %d\n", |
| 9582 | expected_result, result, source1_u, source2_c); |
| 9583 | if (dumped == 0) cod_dump(gen_code); |
| 9584 | failed++; |
| 9585 | dumped++; |
| 9586 | } |
| 9587 | } |
| 9588 | } |
| 9589 | if (verbose) printf(" done\n"); |
| 9590 | cod_free_parse_context(context); |
| 9591 | cod_code_free(gen_code); |
| 9592 | } |
| 9593 | if ((only_run_test == NULL((void*)0)) || |
| 9594 | (strcmp(only_run_test, "u|uc") == 0)) { |
| 9595 | int i, j; |
| 9596 | static char code[] = "{\n\ |
| 9597 | unsigned int a = p1;\n\ |
| 9598 | unsigned char b = p2;\n\ |
| 9599 | return a | b;\n\ |
| 9600 | }"; |
| 9601 | |
| 9602 | unsigned int (*proc)(unsigned int a, unsigned char b); |
| 9603 | cod_parse_context context = new_cod_parse_context(); |
| 9604 | int dumped = 0; |
| 9605 | |
| 9606 | cod_code gen_code; |
| 9607 | |
| 9608 | /* test for unsigned int | unsigned char */ |
| 9609 | if (verbose) printf("test for unsigned int | unsigned char"); |
| 9610 | |
| 9611 | cod_assoc_externs(context, externs); |
| 9612 | cod_parse_for_context(extern_string, context); |
| 9613 | |
| 9614 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, unsigned char p2)", |
| 9615 | context); |
| 9616 | gen_code = cod_code_gen(code, context); |
| 9617 | proc = (unsigned int (*)(unsigned int, unsigned char))(long)gen_code->func; |
| 9618 | |
| 9619 | |
| 9620 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 9621 | unsigned int source1_u = src1u_vals[i]; |
| 9622 | for (j=0 ; j < sizeof(src2uc_vals)/sizeof(src2uc_vals[0]) ; j++) { |
| 9623 | unsigned char source2_uc = src2uc_vals[j]; |
| 9624 | |
| 9625 | unsigned int expected_result; |
| 9626 | unsigned int result; |
| 9627 | |
| 9628 | |
| 9629 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 9630 | |
| 9631 | expected_result = (unsigned int) (source1_u | source2_uc); |
| 9632 | |
| 9633 | result = proc(source1_u, source2_uc); |
| 9634 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 9635 | if (expected_result != result) { |
| 9636 | printf("Failed unsigned int | unsigned char test, expected %u, got %u, for %u | %u\n", |
| 9637 | expected_result, result, source1_u, source2_uc); |
| 9638 | if (dumped == 0) cod_dump(gen_code); |
| 9639 | failed++; |
| 9640 | dumped++; |
| 9641 | } |
| 9642 | } |
| 9643 | } |
| 9644 | if (verbose) printf(" done\n"); |
| 9645 | cod_free_parse_context(context); |
| 9646 | cod_code_free(gen_code); |
| 9647 | } |
| 9648 | if ((only_run_test == NULL((void*)0)) || |
| 9649 | (strcmp(only_run_test, "u|s") == 0)) { |
| 9650 | int i, j; |
| 9651 | static char code[] = "{\n\ |
| 9652 | unsigned int a = p1;\n\ |
| 9653 | short b = p2;\n\ |
| 9654 | return a | b;\n\ |
| 9655 | }"; |
| 9656 | |
| 9657 | unsigned int (*proc)(unsigned int a, short b); |
| 9658 | cod_parse_context context = new_cod_parse_context(); |
| 9659 | int dumped = 0; |
| 9660 | |
| 9661 | cod_code gen_code; |
| 9662 | |
| 9663 | /* test for unsigned int | short */ |
| 9664 | if (verbose) printf("test for unsigned int | short"); |
| 9665 | |
| 9666 | cod_assoc_externs(context, externs); |
| 9667 | cod_parse_for_context(extern_string, context); |
| 9668 | |
| 9669 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, short p2)", |
| 9670 | context); |
| 9671 | gen_code = cod_code_gen(code, context); |
| 9672 | proc = (unsigned int (*)(unsigned int, short))(long)gen_code->func; |
| 9673 | |
| 9674 | |
| 9675 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 9676 | unsigned int source1_u = src1u_vals[i]; |
| 9677 | for (j=0 ; j < sizeof(src2s_vals)/sizeof(src2s_vals[0]) ; j++) { |
| 9678 | short source2_s = src2s_vals[j]; |
| 9679 | |
| 9680 | unsigned int expected_result; |
| 9681 | unsigned int result; |
| 9682 | |
| 9683 | |
| 9684 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 9685 | |
| 9686 | expected_result = (unsigned int) (source1_u | source2_s); |
| 9687 | |
| 9688 | result = proc(source1_u, source2_s); |
| 9689 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 9690 | if (expected_result != result) { |
| 9691 | printf("Failed unsigned int | short test, expected %u, got %u, for %u | %d\n", |
| 9692 | expected_result, result, source1_u, source2_s); |
| 9693 | if (dumped == 0) cod_dump(gen_code); |
| 9694 | failed++; |
| 9695 | dumped++; |
| 9696 | } |
| 9697 | } |
| 9698 | } |
| 9699 | if (verbose) printf(" done\n"); |
| 9700 | cod_free_parse_context(context); |
| 9701 | cod_code_free(gen_code); |
| 9702 | } |
| 9703 | if ((only_run_test == NULL((void*)0)) || |
| 9704 | (strcmp(only_run_test, "u|us") == 0)) { |
| 9705 | int i, j; |
| 9706 | static char code[] = "{\n\ |
| 9707 | unsigned int a = p1;\n\ |
| 9708 | unsigned short b = p2;\n\ |
| 9709 | return a | b;\n\ |
| 9710 | }"; |
| 9711 | |
| 9712 | unsigned int (*proc)(unsigned int a, unsigned short b); |
| 9713 | cod_parse_context context = new_cod_parse_context(); |
| 9714 | int dumped = 0; |
| 9715 | |
| 9716 | cod_code gen_code; |
| 9717 | |
| 9718 | /* test for unsigned int | unsigned short */ |
| 9719 | if (verbose) printf("test for unsigned int | unsigned short"); |
| 9720 | |
| 9721 | cod_assoc_externs(context, externs); |
| 9722 | cod_parse_for_context(extern_string, context); |
| 9723 | |
| 9724 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, unsigned short p2)", |
| 9725 | context); |
| 9726 | gen_code = cod_code_gen(code, context); |
| 9727 | proc = (unsigned int (*)(unsigned int, unsigned short))(long)gen_code->func; |
| 9728 | |
| 9729 | |
| 9730 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 9731 | unsigned int source1_u = src1u_vals[i]; |
| 9732 | for (j=0 ; j < sizeof(src2us_vals)/sizeof(src2us_vals[0]) ; j++) { |
| 9733 | unsigned short source2_us = src2us_vals[j]; |
| 9734 | |
| 9735 | unsigned int expected_result; |
| 9736 | unsigned int result; |
| 9737 | |
| 9738 | |
| 9739 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 9740 | |
| 9741 | expected_result = (unsigned int) (source1_u | source2_us); |
| 9742 | |
| 9743 | result = proc(source1_u, source2_us); |
| 9744 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 9745 | if (expected_result != result) { |
| 9746 | printf("Failed unsigned int | unsigned short test, expected %u, got %u, for %u | %u\n", |
| 9747 | expected_result, result, source1_u, source2_us); |
| 9748 | if (dumped == 0) cod_dump(gen_code); |
| 9749 | failed++; |
| 9750 | dumped++; |
| 9751 | } |
| 9752 | } |
| 9753 | } |
| 9754 | if (verbose) printf(" done\n"); |
| 9755 | cod_free_parse_context(context); |
| 9756 | cod_code_free(gen_code); |
| 9757 | } |
| 9758 | if ((only_run_test == NULL((void*)0)) || |
| 9759 | (strcmp(only_run_test, "u|i") == 0)) { |
| 9760 | int i, j; |
| 9761 | static char code[] = "{\n\ |
| 9762 | unsigned int a = p1;\n\ |
| 9763 | int b = p2;\n\ |
| 9764 | return a | b;\n\ |
| 9765 | }"; |
| 9766 | |
| 9767 | unsigned int (*proc)(unsigned int a, int b); |
| 9768 | cod_parse_context context = new_cod_parse_context(); |
| 9769 | int dumped = 0; |
| 9770 | |
| 9771 | cod_code gen_code; |
| 9772 | |
| 9773 | /* test for unsigned int | int */ |
| 9774 | if (verbose) printf("test for unsigned int | int"); |
| 9775 | |
| 9776 | cod_assoc_externs(context, externs); |
| 9777 | cod_parse_for_context(extern_string, context); |
| 9778 | |
| 9779 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, int p2)", |
| 9780 | context); |
| 9781 | gen_code = cod_code_gen(code, context); |
| 9782 | proc = (unsigned int (*)(unsigned int, int))(long)gen_code->func; |
| 9783 | |
| 9784 | |
| 9785 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 9786 | unsigned int source1_u = src1u_vals[i]; |
| 9787 | for (j=0 ; j < sizeof(src2i_vals)/sizeof(src2i_vals[0]) ; j++) { |
| 9788 | int source2_i = src2i_vals[j]; |
| 9789 | |
| 9790 | unsigned int expected_result; |
| 9791 | unsigned int result; |
| 9792 | |
| 9793 | |
| 9794 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 9795 | |
| 9796 | expected_result = (unsigned int) (source1_u | source2_i); |
| 9797 | |
| 9798 | result = proc(source1_u, source2_i); |
| 9799 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 9800 | if (expected_result != result) { |
| 9801 | printf("Failed unsigned int | int test, expected %u, got %u, for %u | %d\n", |
| 9802 | expected_result, result, source1_u, source2_i); |
| 9803 | if (dumped == 0) cod_dump(gen_code); |
| 9804 | failed++; |
| 9805 | dumped++; |
| 9806 | } |
| 9807 | } |
| 9808 | } |
| 9809 | if (verbose) printf(" done\n"); |
| 9810 | cod_free_parse_context(context); |
| 9811 | cod_code_free(gen_code); |
| 9812 | } |
| 9813 | if ((only_run_test == NULL((void*)0)) || |
| 9814 | (strcmp(only_run_test, "u|u") == 0)) { |
| 9815 | int i, j; |
| 9816 | static char code[] = "{\n\ |
| 9817 | unsigned int a = p1;\n\ |
| 9818 | unsigned int b = p2;\n\ |
| 9819 | return a | b;\n\ |
| 9820 | }"; |
| 9821 | |
| 9822 | unsigned int (*proc)(unsigned int a, unsigned int b); |
| 9823 | cod_parse_context context = new_cod_parse_context(); |
| 9824 | int dumped = 0; |
| 9825 | |
| 9826 | cod_code gen_code; |
| 9827 | |
| 9828 | /* test for unsigned int | unsigned int */ |
| 9829 | if (verbose) printf("test for unsigned int | unsigned int"); |
| 9830 | |
| 9831 | cod_assoc_externs(context, externs); |
| 9832 | cod_parse_for_context(extern_string, context); |
| 9833 | |
| 9834 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, unsigned int p2)", |
| 9835 | context); |
| 9836 | gen_code = cod_code_gen(code, context); |
| 9837 | proc = (unsigned int (*)(unsigned int, unsigned int))(long)gen_code->func; |
| 9838 | |
| 9839 | |
| 9840 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 9841 | unsigned int source1_u = src1u_vals[i]; |
| 9842 | for (j=0 ; j < sizeof(src2u_vals)/sizeof(src2u_vals[0]) ; j++) { |
| 9843 | unsigned int source2_u = src2u_vals[j]; |
| 9844 | |
| 9845 | unsigned int expected_result; |
| 9846 | unsigned int result; |
| 9847 | |
| 9848 | |
| 9849 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 9850 | |
| 9851 | expected_result = (unsigned int) (source1_u | source2_u); |
| 9852 | |
| 9853 | result = proc(source1_u, source2_u); |
| 9854 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 9855 | if (expected_result != result) { |
| 9856 | printf("Failed unsigned int | unsigned int test, expected %u, got %u, for %u | %u\n", |
| 9857 | expected_result, result, source1_u, source2_u); |
| 9858 | if (dumped == 0) cod_dump(gen_code); |
| 9859 | failed++; |
| 9860 | dumped++; |
| 9861 | } |
| 9862 | } |
| 9863 | } |
| 9864 | if (verbose) printf(" done\n"); |
| 9865 | cod_free_parse_context(context); |
| 9866 | cod_code_free(gen_code); |
| 9867 | } |
| 9868 | if ((only_run_test == NULL((void*)0)) || |
| 9869 | (strcmp(only_run_test, "u|ul") == 0)) { |
| 9870 | int i, j; |
| 9871 | static char code[] = "{\n\ |
| 9872 | unsigned int a = p1;\n\ |
| 9873 | unsigned long b = p2;\n\ |
| 9874 | return a | b;\n\ |
| 9875 | }"; |
| 9876 | |
| 9877 | unsigned int (*proc)(unsigned int a, unsigned long b); |
| 9878 | cod_parse_context context = new_cod_parse_context(); |
| 9879 | int dumped = 0; |
| 9880 | |
| 9881 | cod_code gen_code; |
| 9882 | |
| 9883 | /* test for unsigned int | unsigned long */ |
| 9884 | if (verbose) printf("test for unsigned int | unsigned long"); |
| 9885 | |
| 9886 | cod_assoc_externs(context, externs); |
| 9887 | cod_parse_for_context(extern_string, context); |
| 9888 | |
| 9889 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, unsigned long p2)", |
| 9890 | context); |
| 9891 | gen_code = cod_code_gen(code, context); |
| 9892 | proc = (unsigned int (*)(unsigned int, unsigned long))(long)gen_code->func; |
| 9893 | |
| 9894 | |
| 9895 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 9896 | unsigned int source1_u = src1u_vals[i]; |
| 9897 | for (j=0 ; j < sizeof(src2ul_vals)/sizeof(src2ul_vals[0]) ; j++) { |
| 9898 | unsigned long source2_ul = src2ul_vals[j]; |
| 9899 | |
| 9900 | unsigned int expected_result; |
| 9901 | unsigned int result; |
| 9902 | |
| 9903 | |
| 9904 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 9905 | |
| 9906 | expected_result = (unsigned int) (source1_u | source2_ul); |
| 9907 | |
| 9908 | result = proc(source1_u, source2_ul); |
| 9909 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 9910 | if (expected_result != result) { |
| 9911 | printf("Failed unsigned int | unsigned long test, expected %u, got %u, for %u | %lu\n", |
| 9912 | expected_result, result, source1_u, source2_ul); |
| 9913 | if (dumped == 0) cod_dump(gen_code); |
| 9914 | failed++; |
| 9915 | dumped++; |
| 9916 | } |
| 9917 | } |
| 9918 | } |
| 9919 | if (verbose) printf(" done\n"); |
| 9920 | cod_free_parse_context(context); |
| 9921 | cod_code_free(gen_code); |
| 9922 | } |
| 9923 | if ((only_run_test == NULL((void*)0)) || |
| 9924 | (strcmp(only_run_test, "u|l") == 0)) { |
| 9925 | int i, j; |
| 9926 | static char code[] = "{\n\ |
| 9927 | unsigned int a = p1;\n\ |
| 9928 | long b = p2;\n\ |
| 9929 | return a | b;\n\ |
| 9930 | }"; |
| 9931 | |
| 9932 | unsigned int (*proc)(unsigned int a, long b); |
| 9933 | cod_parse_context context = new_cod_parse_context(); |
| 9934 | int dumped = 0; |
| 9935 | |
| 9936 | cod_code gen_code; |
| 9937 | |
| 9938 | /* test for unsigned int | long */ |
| 9939 | if (verbose) printf("test for unsigned int | long"); |
| 9940 | |
| 9941 | cod_assoc_externs(context, externs); |
| 9942 | cod_parse_for_context(extern_string, context); |
| 9943 | |
| 9944 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, long p2)", |
| 9945 | context); |
| 9946 | gen_code = cod_code_gen(code, context); |
| 9947 | proc = (unsigned int (*)(unsigned int, long))(long)gen_code->func; |
| 9948 | |
| 9949 | |
| 9950 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 9951 | unsigned int source1_u = src1u_vals[i]; |
| 9952 | for (j=0 ; j < sizeof(src2l_vals)/sizeof(src2l_vals[0]) ; j++) { |
| 9953 | long source2_l = src2l_vals[j]; |
| 9954 | |
| 9955 | unsigned int expected_result; |
| 9956 | unsigned int result; |
| 9957 | |
| 9958 | |
| 9959 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 9960 | |
| 9961 | expected_result = (unsigned int) (source1_u | source2_l); |
| 9962 | |
| 9963 | result = proc(source1_u, source2_l); |
| 9964 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 9965 | if (expected_result != result) { |
| 9966 | printf("Failed unsigned int | long test, expected %u, got %u, for %u | %ld\n", |
| 9967 | expected_result, result, source1_u, source2_l); |
| 9968 | if (dumped == 0) cod_dump(gen_code); |
| 9969 | failed++; |
| 9970 | dumped++; |
| 9971 | } |
| 9972 | } |
| 9973 | } |
| 9974 | if (verbose) printf(" done\n"); |
| 9975 | cod_free_parse_context(context); |
| 9976 | cod_code_free(gen_code); |
| 9977 | } |
| 9978 | } |
| 9979 | void or_ul_tests() |
| 9980 | { |
| 9981 | if ((only_run_test == NULL((void*)0)) || |
| 9982 | (strcmp(only_run_test, "ul|c") == 0)) { |
| 9983 | int i, j; |
| 9984 | static char code[] = "{\n\ |
| 9985 | unsigned long a = p1;\n\ |
| 9986 | signed char b = p2;\n\ |
| 9987 | return a | b;\n\ |
| 9988 | }"; |
| 9989 | |
| 9990 | unsigned long (*proc)(unsigned long a, signed char b); |
| 9991 | cod_parse_context context = new_cod_parse_context(); |
| 9992 | int dumped = 0; |
| 9993 | |
| 9994 | cod_code gen_code; |
| 9995 | |
| 9996 | /* test for unsigned long | signed char */ |
| 9997 | if (verbose) printf("test for unsigned long | signed char"); |
| 9998 | |
| 9999 | cod_assoc_externs(context, externs); |
| 10000 | cod_parse_for_context(extern_string, context); |
| 10001 | |
| 10002 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, signed char p2)", |
| 10003 | context); |
| 10004 | gen_code = cod_code_gen(code, context); |
| 10005 | proc = (unsigned long (*)(unsigned long, signed char))(long)gen_code->func; |
| 10006 | |
| 10007 | |
| 10008 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 10009 | unsigned long source1_ul = src1ul_vals[i]; |
| 10010 | for (j=0 ; j < sizeof(src2c_vals)/sizeof(src2c_vals[0]) ; j++) { |
| 10011 | signed char source2_c = src2c_vals[j]; |
| 10012 | |
| 10013 | unsigned long expected_result; |
| 10014 | unsigned long result; |
| 10015 | |
| 10016 | |
| 10017 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 10018 | |
| 10019 | expected_result = (unsigned long) (source1_ul | source2_c); |
| 10020 | |
| 10021 | result = proc(source1_ul, source2_c); |
| 10022 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 10023 | if (expected_result != result) { |
| 10024 | printf("Failed unsigned long | signed char test, expected %lu, got %lu, for %lu | %d\n", |
| 10025 | expected_result, result, source1_ul, source2_c); |
| 10026 | if (dumped == 0) cod_dump(gen_code); |
| 10027 | failed++; |
| 10028 | dumped++; |
| 10029 | } |
| 10030 | } |
| 10031 | } |
| 10032 | if (verbose) printf(" done\n"); |
| 10033 | cod_free_parse_context(context); |
| 10034 | cod_code_free(gen_code); |
| 10035 | } |
| 10036 | if ((only_run_test == NULL((void*)0)) || |
| 10037 | (strcmp(only_run_test, "ul|uc") == 0)) { |
| 10038 | int i, j; |
| 10039 | static char code[] = "{\n\ |
| 10040 | unsigned long a = p1;\n\ |
| 10041 | unsigned char b = p2;\n\ |
| 10042 | return a | b;\n\ |
| 10043 | }"; |
| 10044 | |
| 10045 | unsigned long (*proc)(unsigned long a, unsigned char b); |
| 10046 | cod_parse_context context = new_cod_parse_context(); |
| 10047 | int dumped = 0; |
| 10048 | |
| 10049 | cod_code gen_code; |
| 10050 | |
| 10051 | /* test for unsigned long | unsigned char */ |
| 10052 | if (verbose) printf("test for unsigned long | unsigned char"); |
| 10053 | |
| 10054 | cod_assoc_externs(context, externs); |
| 10055 | cod_parse_for_context(extern_string, context); |
| 10056 | |
| 10057 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, unsigned char p2)", |
| 10058 | context); |
| 10059 | gen_code = cod_code_gen(code, context); |
| 10060 | proc = (unsigned long (*)(unsigned long, unsigned char))(long)gen_code->func; |
| 10061 | |
| 10062 | |
| 10063 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 10064 | unsigned long source1_ul = src1ul_vals[i]; |
| 10065 | for (j=0 ; j < sizeof(src2uc_vals)/sizeof(src2uc_vals[0]) ; j++) { |
| 10066 | unsigned char source2_uc = src2uc_vals[j]; |
| 10067 | |
| 10068 | unsigned long expected_result; |
| 10069 | unsigned long result; |
| 10070 | |
| 10071 | |
| 10072 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 10073 | |
| 10074 | expected_result = (unsigned long) (source1_ul | source2_uc); |
| 10075 | |
| 10076 | result = proc(source1_ul, source2_uc); |
| 10077 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 10078 | if (expected_result != result) { |
| 10079 | printf("Failed unsigned long | unsigned char test, expected %lu, got %lu, for %lu | %u\n", |
| 10080 | expected_result, result, source1_ul, source2_uc); |
| 10081 | if (dumped == 0) cod_dump(gen_code); |
| 10082 | failed++; |
| 10083 | dumped++; |
| 10084 | } |
| 10085 | } |
| 10086 | } |
| 10087 | if (verbose) printf(" done\n"); |
| 10088 | cod_free_parse_context(context); |
| 10089 | cod_code_free(gen_code); |
| 10090 | } |
| 10091 | if ((only_run_test == NULL((void*)0)) || |
| 10092 | (strcmp(only_run_test, "ul|s") == 0)) { |
| 10093 | int i, j; |
| 10094 | static char code[] = "{\n\ |
| 10095 | unsigned long a = p1;\n\ |
| 10096 | short b = p2;\n\ |
| 10097 | return a | b;\n\ |
| 10098 | }"; |
| 10099 | |
| 10100 | unsigned long (*proc)(unsigned long a, short b); |
| 10101 | cod_parse_context context = new_cod_parse_context(); |
| 10102 | int dumped = 0; |
| 10103 | |
| 10104 | cod_code gen_code; |
| 10105 | |
| 10106 | /* test for unsigned long | short */ |
| 10107 | if (verbose) printf("test for unsigned long | short"); |
| 10108 | |
| 10109 | cod_assoc_externs(context, externs); |
| 10110 | cod_parse_for_context(extern_string, context); |
| 10111 | |
| 10112 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, short p2)", |
| 10113 | context); |
| 10114 | gen_code = cod_code_gen(code, context); |
| 10115 | proc = (unsigned long (*)(unsigned long, short))(long)gen_code->func; |
| 10116 | |
| 10117 | |
| 10118 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 10119 | unsigned long source1_ul = src1ul_vals[i]; |
| 10120 | for (j=0 ; j < sizeof(src2s_vals)/sizeof(src2s_vals[0]) ; j++) { |
| 10121 | short source2_s = src2s_vals[j]; |
| 10122 | |
| 10123 | unsigned long expected_result; |
| 10124 | unsigned long result; |
| 10125 | |
| 10126 | |
| 10127 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 10128 | |
| 10129 | expected_result = (unsigned long) (source1_ul | source2_s); |
| 10130 | |
| 10131 | result = proc(source1_ul, source2_s); |
| 10132 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 10133 | if (expected_result != result) { |
| 10134 | printf("Failed unsigned long | short test, expected %lu, got %lu, for %lu | %d\n", |
| 10135 | expected_result, result, source1_ul, source2_s); |
| 10136 | if (dumped == 0) cod_dump(gen_code); |
| 10137 | failed++; |
| 10138 | dumped++; |
| 10139 | } |
| 10140 | } |
| 10141 | } |
| 10142 | if (verbose) printf(" done\n"); |
| 10143 | cod_free_parse_context(context); |
| 10144 | cod_code_free(gen_code); |
| 10145 | } |
| 10146 | if ((only_run_test == NULL((void*)0)) || |
| 10147 | (strcmp(only_run_test, "ul|us") == 0)) { |
| 10148 | int i, j; |
| 10149 | static char code[] = "{\n\ |
| 10150 | unsigned long a = p1;\n\ |
| 10151 | unsigned short b = p2;\n\ |
| 10152 | return a | b;\n\ |
| 10153 | }"; |
| 10154 | |
| 10155 | unsigned long (*proc)(unsigned long a, unsigned short b); |
| 10156 | cod_parse_context context = new_cod_parse_context(); |
| 10157 | int dumped = 0; |
| 10158 | |
| 10159 | cod_code gen_code; |
| 10160 | |
| 10161 | /* test for unsigned long | unsigned short */ |
| 10162 | if (verbose) printf("test for unsigned long | unsigned short"); |
| 10163 | |
| 10164 | cod_assoc_externs(context, externs); |
| 10165 | cod_parse_for_context(extern_string, context); |
| 10166 | |
| 10167 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, unsigned short p2)", |
| 10168 | context); |
| 10169 | gen_code = cod_code_gen(code, context); |
| 10170 | proc = (unsigned long (*)(unsigned long, unsigned short))(long)gen_code->func; |
| 10171 | |
| 10172 | |
| 10173 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 10174 | unsigned long source1_ul = src1ul_vals[i]; |
| 10175 | for (j=0 ; j < sizeof(src2us_vals)/sizeof(src2us_vals[0]) ; j++) { |
| 10176 | unsigned short source2_us = src2us_vals[j]; |
| 10177 | |
| 10178 | unsigned long expected_result; |
| 10179 | unsigned long result; |
| 10180 | |
| 10181 | |
| 10182 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 10183 | |
| 10184 | expected_result = (unsigned long) (source1_ul | source2_us); |
| 10185 | |
| 10186 | result = proc(source1_ul, source2_us); |
| 10187 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 10188 | if (expected_result != result) { |
| 10189 | printf("Failed unsigned long | unsigned short test, expected %lu, got %lu, for %lu | %u\n", |
| 10190 | expected_result, result, source1_ul, source2_us); |
| 10191 | if (dumped == 0) cod_dump(gen_code); |
| 10192 | failed++; |
| 10193 | dumped++; |
| 10194 | } |
| 10195 | } |
| 10196 | } |
| 10197 | if (verbose) printf(" done\n"); |
| 10198 | cod_free_parse_context(context); |
| 10199 | cod_code_free(gen_code); |
| 10200 | } |
| 10201 | if ((only_run_test == NULL((void*)0)) || |
| 10202 | (strcmp(only_run_test, "ul|i") == 0)) { |
| 10203 | int i, j; |
| 10204 | static char code[] = "{\n\ |
| 10205 | unsigned long a = p1;\n\ |
| 10206 | int b = p2;\n\ |
| 10207 | return a | b;\n\ |
| 10208 | }"; |
| 10209 | |
| 10210 | unsigned long (*proc)(unsigned long a, int b); |
| 10211 | cod_parse_context context = new_cod_parse_context(); |
| 10212 | int dumped = 0; |
| 10213 | |
| 10214 | cod_code gen_code; |
| 10215 | |
| 10216 | /* test for unsigned long | int */ |
| 10217 | if (verbose) printf("test for unsigned long | int"); |
| 10218 | |
| 10219 | cod_assoc_externs(context, externs); |
| 10220 | cod_parse_for_context(extern_string, context); |
| 10221 | |
| 10222 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, int p2)", |
| 10223 | context); |
| 10224 | gen_code = cod_code_gen(code, context); |
| 10225 | proc = (unsigned long (*)(unsigned long, int))(long)gen_code->func; |
| 10226 | |
| 10227 | |
| 10228 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 10229 | unsigned long source1_ul = src1ul_vals[i]; |
| 10230 | for (j=0 ; j < sizeof(src2i_vals)/sizeof(src2i_vals[0]) ; j++) { |
| 10231 | int source2_i = src2i_vals[j]; |
| 10232 | |
| 10233 | unsigned long expected_result; |
| 10234 | unsigned long result; |
| 10235 | |
| 10236 | |
| 10237 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 10238 | |
| 10239 | expected_result = (unsigned long) (source1_ul | source2_i); |
| 10240 | |
| 10241 | result = proc(source1_ul, source2_i); |
| 10242 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 10243 | if (expected_result != result) { |
| 10244 | printf("Failed unsigned long | int test, expected %lu, got %lu, for %lu | %d\n", |
| 10245 | expected_result, result, source1_ul, source2_i); |
| 10246 | if (dumped == 0) cod_dump(gen_code); |
| 10247 | failed++; |
| 10248 | dumped++; |
| 10249 | } |
| 10250 | } |
| 10251 | } |
| 10252 | if (verbose) printf(" done\n"); |
| 10253 | cod_free_parse_context(context); |
| 10254 | cod_code_free(gen_code); |
| 10255 | } |
| 10256 | if ((only_run_test == NULL((void*)0)) || |
| 10257 | (strcmp(only_run_test, "ul|u") == 0)) { |
| 10258 | int i, j; |
| 10259 | static char code[] = "{\n\ |
| 10260 | unsigned long a = p1;\n\ |
| 10261 | unsigned int b = p2;\n\ |
| 10262 | return a | b;\n\ |
| 10263 | }"; |
| 10264 | |
| 10265 | unsigned long (*proc)(unsigned long a, unsigned int b); |
| 10266 | cod_parse_context context = new_cod_parse_context(); |
| 10267 | int dumped = 0; |
| 10268 | |
| 10269 | cod_code gen_code; |
| 10270 | |
| 10271 | /* test for unsigned long | unsigned int */ |
| 10272 | if (verbose) printf("test for unsigned long | unsigned int"); |
| 10273 | |
| 10274 | cod_assoc_externs(context, externs); |
| 10275 | cod_parse_for_context(extern_string, context); |
| 10276 | |
| 10277 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, unsigned int p2)", |
| 10278 | context); |
| 10279 | gen_code = cod_code_gen(code, context); |
| 10280 | proc = (unsigned long (*)(unsigned long, unsigned int))(long)gen_code->func; |
| 10281 | |
| 10282 | |
| 10283 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 10284 | unsigned long source1_ul = src1ul_vals[i]; |
| 10285 | for (j=0 ; j < sizeof(src2u_vals)/sizeof(src2u_vals[0]) ; j++) { |
| 10286 | unsigned int source2_u = src2u_vals[j]; |
| 10287 | |
| 10288 | unsigned long expected_result; |
| 10289 | unsigned long result; |
| 10290 | |
| 10291 | |
| 10292 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 10293 | |
| 10294 | expected_result = (unsigned long) (source1_ul | source2_u); |
| 10295 | |
| 10296 | result = proc(source1_ul, source2_u); |
| 10297 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 10298 | if (expected_result != result) { |
| 10299 | printf("Failed unsigned long | unsigned int test, expected %lu, got %lu, for %lu | %u\n", |
| 10300 | expected_result, result, source1_ul, source2_u); |
| 10301 | if (dumped == 0) cod_dump(gen_code); |
| 10302 | failed++; |
| 10303 | dumped++; |
| 10304 | } |
| 10305 | } |
| 10306 | } |
| 10307 | if (verbose) printf(" done\n"); |
| 10308 | cod_free_parse_context(context); |
| 10309 | cod_code_free(gen_code); |
| 10310 | } |
| 10311 | if ((only_run_test == NULL((void*)0)) || |
| 10312 | (strcmp(only_run_test, "ul|ul") == 0)) { |
| 10313 | int i, j; |
| 10314 | static char code[] = "{\n\ |
| 10315 | unsigned long a = p1;\n\ |
| 10316 | unsigned long b = p2;\n\ |
| 10317 | return a | b;\n\ |
| 10318 | }"; |
| 10319 | |
| 10320 | unsigned long (*proc)(unsigned long a, unsigned long b); |
| 10321 | cod_parse_context context = new_cod_parse_context(); |
| 10322 | int dumped = 0; |
| 10323 | |
| 10324 | cod_code gen_code; |
| 10325 | |
| 10326 | /* test for unsigned long | unsigned long */ |
| 10327 | if (verbose) printf("test for unsigned long | unsigned long"); |
| 10328 | |
| 10329 | cod_assoc_externs(context, externs); |
| 10330 | cod_parse_for_context(extern_string, context); |
| 10331 | |
| 10332 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, unsigned long p2)", |
| 10333 | context); |
| 10334 | gen_code = cod_code_gen(code, context); |
| 10335 | proc = (unsigned long (*)(unsigned long, unsigned long))(long)gen_code->func; |
| 10336 | |
| 10337 | |
| 10338 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 10339 | unsigned long source1_ul = src1ul_vals[i]; |
| 10340 | for (j=0 ; j < sizeof(src2ul_vals)/sizeof(src2ul_vals[0]) ; j++) { |
| 10341 | unsigned long source2_ul = src2ul_vals[j]; |
| 10342 | |
| 10343 | unsigned long expected_result; |
| 10344 | unsigned long result; |
| 10345 | |
| 10346 | |
| 10347 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 10348 | |
| 10349 | expected_result = (unsigned long) (source1_ul | source2_ul); |
| 10350 | |
| 10351 | result = proc(source1_ul, source2_ul); |
| 10352 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 10353 | if (expected_result != result) { |
| 10354 | printf("Failed unsigned long | unsigned long test, expected %lu, got %lu, for %lu | %lu\n", |
| 10355 | expected_result, result, source1_ul, source2_ul); |
| 10356 | if (dumped == 0) cod_dump(gen_code); |
| 10357 | failed++; |
| 10358 | dumped++; |
| 10359 | } |
| 10360 | } |
| 10361 | } |
| 10362 | if (verbose) printf(" done\n"); |
| 10363 | cod_free_parse_context(context); |
| 10364 | cod_code_free(gen_code); |
| 10365 | } |
| 10366 | if ((only_run_test == NULL((void*)0)) || |
| 10367 | (strcmp(only_run_test, "ul|l") == 0)) { |
| 10368 | int i, j; |
| 10369 | static char code[] = "{\n\ |
| 10370 | unsigned long a = p1;\n\ |
| 10371 | long b = p2;\n\ |
| 10372 | return a | b;\n\ |
| 10373 | }"; |
| 10374 | |
| 10375 | unsigned long (*proc)(unsigned long a, long b); |
| 10376 | cod_parse_context context = new_cod_parse_context(); |
| 10377 | int dumped = 0; |
| 10378 | |
| 10379 | cod_code gen_code; |
| 10380 | |
| 10381 | /* test for unsigned long | long */ |
| 10382 | if (verbose) printf("test for unsigned long | long"); |
| 10383 | |
| 10384 | cod_assoc_externs(context, externs); |
| 10385 | cod_parse_for_context(extern_string, context); |
| 10386 | |
| 10387 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, long p2)", |
| 10388 | context); |
| 10389 | gen_code = cod_code_gen(code, context); |
| 10390 | proc = (unsigned long (*)(unsigned long, long))(long)gen_code->func; |
| 10391 | |
| 10392 | |
| 10393 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 10394 | unsigned long source1_ul = src1ul_vals[i]; |
| 10395 | for (j=0 ; j < sizeof(src2l_vals)/sizeof(src2l_vals[0]) ; j++) { |
| 10396 | long source2_l = src2l_vals[j]; |
| 10397 | |
| 10398 | unsigned long expected_result; |
| 10399 | unsigned long result; |
| 10400 | |
| 10401 | |
| 10402 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 10403 | |
| 10404 | expected_result = (unsigned long) (source1_ul | source2_l); |
| 10405 | |
| 10406 | result = proc(source1_ul, source2_l); |
| 10407 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 10408 | if (expected_result != result) { |
| 10409 | printf("Failed unsigned long | long test, expected %lu, got %lu, for %lu | %ld\n", |
| 10410 | expected_result, result, source1_ul, source2_l); |
| 10411 | if (dumped == 0) cod_dump(gen_code); |
| 10412 | failed++; |
| 10413 | dumped++; |
| 10414 | } |
| 10415 | } |
| 10416 | } |
| 10417 | if (verbose) printf(" done\n"); |
| 10418 | cod_free_parse_context(context); |
| 10419 | cod_code_free(gen_code); |
| 10420 | } |
| 10421 | } |
| 10422 | void or_l_tests() |
| 10423 | { |
| 10424 | if ((only_run_test == NULL((void*)0)) || |
| 10425 | (strcmp(only_run_test, "l|c") == 0)) { |
| 10426 | int i, j; |
| 10427 | static char code[] = "{\n\ |
| 10428 | long a = p1;\n\ |
| 10429 | signed char b = p2;\n\ |
| 10430 | return a | b;\n\ |
| 10431 | }"; |
| 10432 | |
| 10433 | long (*proc)(long a, signed char b); |
| 10434 | cod_parse_context context = new_cod_parse_context(); |
| 10435 | int dumped = 0; |
| 10436 | |
| 10437 | cod_code gen_code; |
| 10438 | |
| 10439 | /* test for long | signed char */ |
| 10440 | if (verbose) printf("test for long | signed char"); |
| 10441 | |
| 10442 | cod_assoc_externs(context, externs); |
| 10443 | cod_parse_for_context(extern_string, context); |
| 10444 | |
| 10445 | cod_subroutine_declaration("long proc(long p1, signed char p2)", |
| 10446 | context); |
| 10447 | gen_code = cod_code_gen(code, context); |
| 10448 | proc = (long (*)(long, signed char))(long)gen_code->func; |
| 10449 | |
| 10450 | |
| 10451 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 10452 | long source1_l = src1l_vals[i]; |
| 10453 | for (j=0 ; j < sizeof(src2c_vals)/sizeof(src2c_vals[0]) ; j++) { |
| 10454 | signed char source2_c = src2c_vals[j]; |
| 10455 | |
| 10456 | long expected_result; |
| 10457 | long result; |
| 10458 | |
| 10459 | |
| 10460 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 10461 | |
| 10462 | expected_result = (long) (source1_l | source2_c); |
| 10463 | |
| 10464 | result = proc(source1_l, source2_c); |
| 10465 | if (expected_result != result) { |
| 10466 | printf("Failed long | signed char test, expected %ld, got %ld, for %ld | %d\n", |
| 10467 | expected_result, result, source1_l, source2_c); |
| 10468 | if (dumped == 0) cod_dump(gen_code); |
| 10469 | failed++; |
| 10470 | dumped++; |
| 10471 | } |
| 10472 | } |
| 10473 | } |
| 10474 | if (verbose) printf(" done\n"); |
| 10475 | cod_free_parse_context(context); |
| 10476 | cod_code_free(gen_code); |
| 10477 | } |
| 10478 | if ((only_run_test == NULL((void*)0)) || |
| 10479 | (strcmp(only_run_test, "l|uc") == 0)) { |
| 10480 | int i, j; |
| 10481 | static char code[] = "{\n\ |
| 10482 | long a = p1;\n\ |
| 10483 | unsigned char b = p2;\n\ |
| 10484 | return a | b;\n\ |
| 10485 | }"; |
| 10486 | |
| 10487 | long (*proc)(long a, unsigned char b); |
| 10488 | cod_parse_context context = new_cod_parse_context(); |
| 10489 | int dumped = 0; |
| 10490 | |
| 10491 | cod_code gen_code; |
| 10492 | |
| 10493 | /* test for long | unsigned char */ |
| 10494 | if (verbose) printf("test for long | unsigned char"); |
| 10495 | |
| 10496 | cod_assoc_externs(context, externs); |
| 10497 | cod_parse_for_context(extern_string, context); |
| 10498 | |
| 10499 | cod_subroutine_declaration("long proc(long p1, unsigned char p2)", |
| 10500 | context); |
| 10501 | gen_code = cod_code_gen(code, context); |
| 10502 | proc = (long (*)(long, unsigned char))(long)gen_code->func; |
| 10503 | |
| 10504 | |
| 10505 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 10506 | long source1_l = src1l_vals[i]; |
| 10507 | for (j=0 ; j < sizeof(src2uc_vals)/sizeof(src2uc_vals[0]) ; j++) { |
| 10508 | unsigned char source2_uc = src2uc_vals[j]; |
| 10509 | |
| 10510 | long expected_result; |
| 10511 | long result; |
| 10512 | |
| 10513 | |
| 10514 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 10515 | |
| 10516 | expected_result = (long) (source1_l | source2_uc); |
| 10517 | |
| 10518 | result = proc(source1_l, source2_uc); |
| 10519 | if (expected_result != result) { |
| 10520 | printf("Failed long | unsigned char test, expected %ld, got %ld, for %ld | %u\n", |
| 10521 | expected_result, result, source1_l, source2_uc); |
| 10522 | if (dumped == 0) cod_dump(gen_code); |
| 10523 | failed++; |
| 10524 | dumped++; |
| 10525 | } |
| 10526 | } |
| 10527 | } |
| 10528 | if (verbose) printf(" done\n"); |
| 10529 | cod_free_parse_context(context); |
| 10530 | cod_code_free(gen_code); |
| 10531 | } |
| 10532 | if ((only_run_test == NULL((void*)0)) || |
| 10533 | (strcmp(only_run_test, "l|s") == 0)) { |
| 10534 | int i, j; |
| 10535 | static char code[] = "{\n\ |
| 10536 | long a = p1;\n\ |
| 10537 | short b = p2;\n\ |
| 10538 | return a | b;\n\ |
| 10539 | }"; |
| 10540 | |
| 10541 | long (*proc)(long a, short b); |
| 10542 | cod_parse_context context = new_cod_parse_context(); |
| 10543 | int dumped = 0; |
| 10544 | |
| 10545 | cod_code gen_code; |
| 10546 | |
| 10547 | /* test for long | short */ |
| 10548 | if (verbose) printf("test for long | short"); |
| 10549 | |
| 10550 | cod_assoc_externs(context, externs); |
| 10551 | cod_parse_for_context(extern_string, context); |
| 10552 | |
| 10553 | cod_subroutine_declaration("long proc(long p1, short p2)", |
| 10554 | context); |
| 10555 | gen_code = cod_code_gen(code, context); |
| 10556 | proc = (long (*)(long, short))(long)gen_code->func; |
| 10557 | |
| 10558 | |
| 10559 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 10560 | long source1_l = src1l_vals[i]; |
| 10561 | for (j=0 ; j < sizeof(src2s_vals)/sizeof(src2s_vals[0]) ; j++) { |
| 10562 | short source2_s = src2s_vals[j]; |
| 10563 | |
| 10564 | long expected_result; |
| 10565 | long result; |
| 10566 | |
| 10567 | |
| 10568 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 10569 | |
| 10570 | expected_result = (long) (source1_l | source2_s); |
| 10571 | |
| 10572 | result = proc(source1_l, source2_s); |
| 10573 | if (expected_result != result) { |
| 10574 | printf("Failed long | short test, expected %ld, got %ld, for %ld | %d\n", |
| 10575 | expected_result, result, source1_l, source2_s); |
| 10576 | if (dumped == 0) cod_dump(gen_code); |
| 10577 | failed++; |
| 10578 | dumped++; |
| 10579 | } |
| 10580 | } |
| 10581 | } |
| 10582 | if (verbose) printf(" done\n"); |
| 10583 | cod_free_parse_context(context); |
| 10584 | cod_code_free(gen_code); |
| 10585 | } |
| 10586 | if ((only_run_test == NULL((void*)0)) || |
| 10587 | (strcmp(only_run_test, "l|us") == 0)) { |
| 10588 | int i, j; |
| 10589 | static char code[] = "{\n\ |
| 10590 | long a = p1;\n\ |
| 10591 | unsigned short b = p2;\n\ |
| 10592 | return a | b;\n\ |
| 10593 | }"; |
| 10594 | |
| 10595 | long (*proc)(long a, unsigned short b); |
| 10596 | cod_parse_context context = new_cod_parse_context(); |
| 10597 | int dumped = 0; |
| 10598 | |
| 10599 | cod_code gen_code; |
| 10600 | |
| 10601 | /* test for long | unsigned short */ |
| 10602 | if (verbose) printf("test for long | unsigned short"); |
| 10603 | |
| 10604 | cod_assoc_externs(context, externs); |
| 10605 | cod_parse_for_context(extern_string, context); |
| 10606 | |
| 10607 | cod_subroutine_declaration("long proc(long p1, unsigned short p2)", |
| 10608 | context); |
| 10609 | gen_code = cod_code_gen(code, context); |
| 10610 | proc = (long (*)(long, unsigned short))(long)gen_code->func; |
| 10611 | |
| 10612 | |
| 10613 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 10614 | long source1_l = src1l_vals[i]; |
| 10615 | for (j=0 ; j < sizeof(src2us_vals)/sizeof(src2us_vals[0]) ; j++) { |
| 10616 | unsigned short source2_us = src2us_vals[j]; |
| 10617 | |
| 10618 | long expected_result; |
| 10619 | long result; |
| 10620 | |
| 10621 | |
| 10622 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 10623 | |
| 10624 | expected_result = (long) (source1_l | source2_us); |
| 10625 | |
| 10626 | result = proc(source1_l, source2_us); |
| 10627 | if (expected_result != result) { |
| 10628 | printf("Failed long | unsigned short test, expected %ld, got %ld, for %ld | %u\n", |
| 10629 | expected_result, result, source1_l, source2_us); |
| 10630 | if (dumped == 0) cod_dump(gen_code); |
| 10631 | failed++; |
| 10632 | dumped++; |
| 10633 | } |
| 10634 | } |
| 10635 | } |
| 10636 | if (verbose) printf(" done\n"); |
| 10637 | cod_free_parse_context(context); |
| 10638 | cod_code_free(gen_code); |
| 10639 | } |
| 10640 | if ((only_run_test == NULL((void*)0)) || |
| 10641 | (strcmp(only_run_test, "l|i") == 0)) { |
| 10642 | int i, j; |
| 10643 | static char code[] = "{\n\ |
| 10644 | long a = p1;\n\ |
| 10645 | int b = p2;\n\ |
| 10646 | return a | b;\n\ |
| 10647 | }"; |
| 10648 | |
| 10649 | long (*proc)(long a, int b); |
| 10650 | cod_parse_context context = new_cod_parse_context(); |
| 10651 | int dumped = 0; |
| 10652 | |
| 10653 | cod_code gen_code; |
| 10654 | |
| 10655 | /* test for long | int */ |
| 10656 | if (verbose) printf("test for long | int"); |
| 10657 | |
| 10658 | cod_assoc_externs(context, externs); |
| 10659 | cod_parse_for_context(extern_string, context); |
| 10660 | |
| 10661 | cod_subroutine_declaration("long proc(long p1, int p2)", |
| 10662 | context); |
| 10663 | gen_code = cod_code_gen(code, context); |
| 10664 | proc = (long (*)(long, int))(long)gen_code->func; |
| 10665 | |
| 10666 | |
| 10667 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 10668 | long source1_l = src1l_vals[i]; |
| 10669 | for (j=0 ; j < sizeof(src2i_vals)/sizeof(src2i_vals[0]) ; j++) { |
| 10670 | int source2_i = src2i_vals[j]; |
| 10671 | |
| 10672 | long expected_result; |
| 10673 | long result; |
| 10674 | |
| 10675 | |
| 10676 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 10677 | |
| 10678 | expected_result = (long) (source1_l | source2_i); |
| 10679 | |
| 10680 | result = proc(source1_l, source2_i); |
| 10681 | if (expected_result != result) { |
| 10682 | printf("Failed long | int test, expected %ld, got %ld, for %ld | %d\n", |
| 10683 | expected_result, result, source1_l, source2_i); |
| 10684 | if (dumped == 0) cod_dump(gen_code); |
| 10685 | failed++; |
| 10686 | dumped++; |
| 10687 | } |
| 10688 | } |
| 10689 | } |
| 10690 | if (verbose) printf(" done\n"); |
| 10691 | cod_free_parse_context(context); |
| 10692 | cod_code_free(gen_code); |
| 10693 | } |
| 10694 | if ((only_run_test == NULL((void*)0)) || |
| 10695 | (strcmp(only_run_test, "l|u") == 0)) { |
| 10696 | int i, j; |
| 10697 | static char code[] = "{\n\ |
| 10698 | long a = p1;\n\ |
| 10699 | unsigned int b = p2;\n\ |
| 10700 | return a | b;\n\ |
| 10701 | }"; |
| 10702 | |
| 10703 | long (*proc)(long a, unsigned int b); |
| 10704 | cod_parse_context context = new_cod_parse_context(); |
| 10705 | int dumped = 0; |
| 10706 | |
| 10707 | cod_code gen_code; |
| 10708 | |
| 10709 | /* test for long | unsigned int */ |
| 10710 | if (verbose) printf("test for long | unsigned int"); |
| 10711 | |
| 10712 | cod_assoc_externs(context, externs); |
| 10713 | cod_parse_for_context(extern_string, context); |
| 10714 | |
| 10715 | cod_subroutine_declaration("long proc(long p1, unsigned int p2)", |
| 10716 | context); |
| 10717 | gen_code = cod_code_gen(code, context); |
| 10718 | proc = (long (*)(long, unsigned int))(long)gen_code->func; |
| 10719 | |
| 10720 | |
| 10721 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 10722 | long source1_l = src1l_vals[i]; |
| 10723 | for (j=0 ; j < sizeof(src2u_vals)/sizeof(src2u_vals[0]) ; j++) { |
| 10724 | unsigned int source2_u = src2u_vals[j]; |
| 10725 | |
| 10726 | long expected_result; |
| 10727 | long result; |
| 10728 | |
| 10729 | |
| 10730 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 10731 | |
| 10732 | expected_result = (long) (source1_l | source2_u); |
| 10733 | |
| 10734 | result = proc(source1_l, source2_u); |
| 10735 | if (expected_result != result) { |
| 10736 | printf("Failed long | unsigned int test, expected %ld, got %ld, for %ld | %u\n", |
| 10737 | expected_result, result, source1_l, source2_u); |
| 10738 | if (dumped == 0) cod_dump(gen_code); |
| 10739 | failed++; |
| 10740 | dumped++; |
| 10741 | } |
| 10742 | } |
| 10743 | } |
| 10744 | if (verbose) printf(" done\n"); |
| 10745 | cod_free_parse_context(context); |
| 10746 | cod_code_free(gen_code); |
| 10747 | } |
| 10748 | if ((only_run_test == NULL((void*)0)) || |
| 10749 | (strcmp(only_run_test, "l|ul") == 0)) { |
| 10750 | int i, j; |
| 10751 | static char code[] = "{\n\ |
| 10752 | long a = p1;\n\ |
| 10753 | unsigned long b = p2;\n\ |
| 10754 | return a | b;\n\ |
| 10755 | }"; |
| 10756 | |
| 10757 | long (*proc)(long a, unsigned long b); |
| 10758 | cod_parse_context context = new_cod_parse_context(); |
| 10759 | int dumped = 0; |
| 10760 | |
| 10761 | cod_code gen_code; |
| 10762 | |
| 10763 | /* test for long | unsigned long */ |
| 10764 | if (verbose) printf("test for long | unsigned long"); |
| 10765 | |
| 10766 | cod_assoc_externs(context, externs); |
| 10767 | cod_parse_for_context(extern_string, context); |
| 10768 | |
| 10769 | cod_subroutine_declaration("long proc(long p1, unsigned long p2)", |
| 10770 | context); |
| 10771 | gen_code = cod_code_gen(code, context); |
| 10772 | proc = (long (*)(long, unsigned long))(long)gen_code->func; |
| 10773 | |
| 10774 | |
| 10775 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 10776 | long source1_l = src1l_vals[i]; |
| 10777 | for (j=0 ; j < sizeof(src2ul_vals)/sizeof(src2ul_vals[0]) ; j++) { |
| 10778 | unsigned long source2_ul = src2ul_vals[j]; |
| 10779 | |
| 10780 | long expected_result; |
| 10781 | long result; |
| 10782 | |
| 10783 | |
| 10784 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 10785 | |
| 10786 | expected_result = (long) (source1_l | source2_ul); |
| 10787 | |
| 10788 | result = proc(source1_l, source2_ul); |
| 10789 | if (expected_result != result) { |
| 10790 | printf("Failed long | unsigned long test, expected %ld, got %ld, for %ld | %lu\n", |
| 10791 | expected_result, result, source1_l, source2_ul); |
| 10792 | if (dumped == 0) cod_dump(gen_code); |
| 10793 | failed++; |
| 10794 | dumped++; |
| 10795 | } |
| 10796 | } |
| 10797 | } |
| 10798 | if (verbose) printf(" done\n"); |
| 10799 | cod_free_parse_context(context); |
| 10800 | cod_code_free(gen_code); |
| 10801 | } |
| 10802 | if ((only_run_test == NULL((void*)0)) || |
| 10803 | (strcmp(only_run_test, "l|l") == 0)) { |
| 10804 | int i, j; |
| 10805 | static char code[] = "{\n\ |
| 10806 | long a = p1;\n\ |
| 10807 | long b = p2;\n\ |
| 10808 | return a | b;\n\ |
| 10809 | }"; |
| 10810 | |
| 10811 | long (*proc)(long a, long b); |
| 10812 | cod_parse_context context = new_cod_parse_context(); |
| 10813 | int dumped = 0; |
| 10814 | |
| 10815 | cod_code gen_code; |
| 10816 | |
| 10817 | /* test for long | long */ |
| 10818 | if (verbose) printf("test for long | long"); |
| 10819 | |
| 10820 | cod_assoc_externs(context, externs); |
| 10821 | cod_parse_for_context(extern_string, context); |
| 10822 | |
| 10823 | cod_subroutine_declaration("long proc(long p1, long p2)", |
| 10824 | context); |
| 10825 | gen_code = cod_code_gen(code, context); |
| 10826 | proc = (long (*)(long, long))(long)gen_code->func; |
| 10827 | |
| 10828 | |
| 10829 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 10830 | long source1_l = src1l_vals[i]; |
| 10831 | for (j=0 ; j < sizeof(src2l_vals)/sizeof(src2l_vals[0]) ; j++) { |
| 10832 | long source2_l = src2l_vals[j]; |
| 10833 | |
| 10834 | long expected_result; |
| 10835 | long result; |
| 10836 | |
| 10837 | |
| 10838 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 10839 | |
| 10840 | expected_result = (long) (source1_l | source2_l); |
| 10841 | |
| 10842 | result = proc(source1_l, source2_l); |
| 10843 | if (expected_result != result) { |
| 10844 | printf("Failed long | long test, expected %ld, got %ld, for %ld | %ld\n", |
| 10845 | expected_result, result, source1_l, source2_l); |
| 10846 | if (dumped == 0) cod_dump(gen_code); |
| 10847 | failed++; |
| 10848 | dumped++; |
| 10849 | } |
| 10850 | } |
| 10851 | } |
| 10852 | if (verbose) printf(" done\n"); |
| 10853 | cod_free_parse_context(context); |
| 10854 | cod_code_free(gen_code); |
| 10855 | } |
| 10856 | } |
| 10857 | void not_c_tests() |
| 10858 | { |
| 10859 | if ((only_run_test == NULL((void*)0)) || |
| 10860 | (strcmp(only_run_test, "c^c") == 0)) { |
| 10861 | int i, j; |
| 10862 | static char code[] = "{\n\ |
| 10863 | signed char a = p1;\n\ |
| 10864 | signed char b = p2;\n\ |
| 10865 | return a ^ b;\n\ |
| 10866 | }"; |
| 10867 | |
| 10868 | signed char (*proc)(signed char a, signed char b); |
| 10869 | cod_parse_context context = new_cod_parse_context(); |
| 10870 | int dumped = 0; |
| 10871 | |
| 10872 | cod_code gen_code; |
| 10873 | |
| 10874 | /* test for signed char ^ signed char */ |
| 10875 | if (verbose) printf("test for signed char ^ signed char"); |
| 10876 | |
| 10877 | cod_assoc_externs(context, externs); |
| 10878 | cod_parse_for_context(extern_string, context); |
| 10879 | |
| 10880 | cod_subroutine_declaration("signed char proc(signed char p1, signed char p2)", |
| 10881 | context); |
| 10882 | gen_code = cod_code_gen(code, context); |
| 10883 | proc = (signed char (*)(signed char, signed char))(long)gen_code->func; |
| 10884 | |
| 10885 | |
| 10886 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 10887 | signed char source1_c = src1c_vals[i]; |
| 10888 | for (j=0 ; j < sizeof(src2c_vals)/sizeof(src2c_vals[0]) ; j++) { |
| 10889 | signed char source2_c = src2c_vals[j]; |
| 10890 | |
| 10891 | signed char expected_result; |
| 10892 | signed char result; |
| 10893 | |
| 10894 | |
| 10895 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 10896 | |
| 10897 | expected_result = (signed char) (source1_c ^ source2_c); |
| 10898 | |
| 10899 | result = proc(source1_c, source2_c); |
| 10900 | if (expected_result != result) { |
| 10901 | printf("Failed signed char ^ signed char test, expected %d, got %d, for %d ^ %d\n", |
| 10902 | expected_result, result, source1_c, source2_c); |
| 10903 | if (dumped == 0) cod_dump(gen_code); |
| 10904 | failed++; |
| 10905 | dumped++; |
| 10906 | } |
| 10907 | } |
| 10908 | } |
| 10909 | if (verbose) printf(" done\n"); |
| 10910 | cod_free_parse_context(context); |
| 10911 | cod_code_free(gen_code); |
| 10912 | } |
| 10913 | if ((only_run_test == NULL((void*)0)) || |
| 10914 | (strcmp(only_run_test, "c^uc") == 0)) { |
| 10915 | int i, j; |
| 10916 | static char code[] = "{\n\ |
| 10917 | signed char a = p1;\n\ |
| 10918 | unsigned char b = p2;\n\ |
| 10919 | return a ^ b;\n\ |
| 10920 | }"; |
| 10921 | |
| 10922 | signed char (*proc)(signed char a, unsigned char b); |
| 10923 | cod_parse_context context = new_cod_parse_context(); |
| 10924 | int dumped = 0; |
| 10925 | |
| 10926 | cod_code gen_code; |
| 10927 | |
| 10928 | /* test for signed char ^ unsigned char */ |
| 10929 | if (verbose) printf("test for signed char ^ unsigned char"); |
| 10930 | |
| 10931 | cod_assoc_externs(context, externs); |
| 10932 | cod_parse_for_context(extern_string, context); |
| 10933 | |
| 10934 | cod_subroutine_declaration("signed char proc(signed char p1, unsigned char p2)", |
| 10935 | context); |
| 10936 | gen_code = cod_code_gen(code, context); |
| 10937 | proc = (signed char (*)(signed char, unsigned char))(long)gen_code->func; |
| 10938 | |
| 10939 | |
| 10940 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 10941 | signed char source1_c = src1c_vals[i]; |
| 10942 | for (j=0 ; j < sizeof(src2uc_vals)/sizeof(src2uc_vals[0]) ; j++) { |
| 10943 | unsigned char source2_uc = src2uc_vals[j]; |
| 10944 | |
| 10945 | signed char expected_result; |
| 10946 | signed char result; |
| 10947 | |
| 10948 | |
| 10949 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 10950 | |
| 10951 | expected_result = (signed char) (source1_c ^ source2_uc); |
| 10952 | |
| 10953 | result = proc(source1_c, source2_uc); |
| 10954 | if (expected_result != result) { |
| 10955 | printf("Failed signed char ^ unsigned char test, expected %d, got %d, for %d ^ %u\n", |
| 10956 | expected_result, result, source1_c, source2_uc); |
| 10957 | if (dumped == 0) cod_dump(gen_code); |
| 10958 | failed++; |
| 10959 | dumped++; |
| 10960 | } |
| 10961 | } |
| 10962 | } |
| 10963 | if (verbose) printf(" done\n"); |
| 10964 | cod_free_parse_context(context); |
| 10965 | cod_code_free(gen_code); |
| 10966 | } |
| 10967 | if ((only_run_test == NULL((void*)0)) || |
| 10968 | (strcmp(only_run_test, "c^s") == 0)) { |
| 10969 | int i, j; |
| 10970 | static char code[] = "{\n\ |
| 10971 | signed char a = p1;\n\ |
| 10972 | short b = p2;\n\ |
| 10973 | return a ^ b;\n\ |
| 10974 | }"; |
| 10975 | |
| 10976 | signed char (*proc)(signed char a, short b); |
| 10977 | cod_parse_context context = new_cod_parse_context(); |
| 10978 | int dumped = 0; |
| 10979 | |
| 10980 | cod_code gen_code; |
| 10981 | |
| 10982 | /* test for signed char ^ short */ |
| 10983 | if (verbose) printf("test for signed char ^ short"); |
| 10984 | |
| 10985 | cod_assoc_externs(context, externs); |
| 10986 | cod_parse_for_context(extern_string, context); |
| 10987 | |
| 10988 | cod_subroutine_declaration("signed char proc(signed char p1, short p2)", |
| 10989 | context); |
| 10990 | gen_code = cod_code_gen(code, context); |
| 10991 | proc = (signed char (*)(signed char, short))(long)gen_code->func; |
| 10992 | |
| 10993 | |
| 10994 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 10995 | signed char source1_c = src1c_vals[i]; |
| 10996 | for (j=0 ; j < sizeof(src2s_vals)/sizeof(src2s_vals[0]) ; j++) { |
| 10997 | short source2_s = src2s_vals[j]; |
| 10998 | |
| 10999 | signed char expected_result; |
| 11000 | signed char result; |
| 11001 | |
| 11002 | |
| 11003 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 11004 | |
| 11005 | expected_result = (signed char) (source1_c ^ source2_s); |
| 11006 | |
| 11007 | result = proc(source1_c, source2_s); |
| 11008 | if (expected_result != result) { |
| 11009 | printf("Failed signed char ^ short test, expected %d, got %d, for %d ^ %d\n", |
| 11010 | expected_result, result, source1_c, source2_s); |
| 11011 | if (dumped == 0) cod_dump(gen_code); |
| 11012 | failed++; |
| 11013 | dumped++; |
| 11014 | } |
| 11015 | } |
| 11016 | } |
| 11017 | if (verbose) printf(" done\n"); |
| 11018 | cod_free_parse_context(context); |
| 11019 | cod_code_free(gen_code); |
| 11020 | } |
| 11021 | if ((only_run_test == NULL((void*)0)) || |
| 11022 | (strcmp(only_run_test, "c^us") == 0)) { |
| 11023 | int i, j; |
| 11024 | static char code[] = "{\n\ |
| 11025 | signed char a = p1;\n\ |
| 11026 | unsigned short b = p2;\n\ |
| 11027 | return a ^ b;\n\ |
| 11028 | }"; |
| 11029 | |
| 11030 | signed char (*proc)(signed char a, unsigned short b); |
| 11031 | cod_parse_context context = new_cod_parse_context(); |
| 11032 | int dumped = 0; |
| 11033 | |
| 11034 | cod_code gen_code; |
| 11035 | |
| 11036 | /* test for signed char ^ unsigned short */ |
| 11037 | if (verbose) printf("test for signed char ^ unsigned short"); |
| 11038 | |
| 11039 | cod_assoc_externs(context, externs); |
| 11040 | cod_parse_for_context(extern_string, context); |
| 11041 | |
| 11042 | cod_subroutine_declaration("signed char proc(signed char p1, unsigned short p2)", |
| 11043 | context); |
| 11044 | gen_code = cod_code_gen(code, context); |
| 11045 | proc = (signed char (*)(signed char, unsigned short))(long)gen_code->func; |
| 11046 | |
| 11047 | |
| 11048 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 11049 | signed char source1_c = src1c_vals[i]; |
| 11050 | for (j=0 ; j < sizeof(src2us_vals)/sizeof(src2us_vals[0]) ; j++) { |
| 11051 | unsigned short source2_us = src2us_vals[j]; |
| 11052 | |
| 11053 | signed char expected_result; |
| 11054 | signed char result; |
| 11055 | |
| 11056 | |
| 11057 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 11058 | |
| 11059 | expected_result = (signed char) (source1_c ^ source2_us); |
| 11060 | |
| 11061 | result = proc(source1_c, source2_us); |
| 11062 | if (expected_result != result) { |
| 11063 | printf("Failed signed char ^ unsigned short test, expected %d, got %d, for %d ^ %u\n", |
| 11064 | expected_result, result, source1_c, source2_us); |
| 11065 | if (dumped == 0) cod_dump(gen_code); |
| 11066 | failed++; |
| 11067 | dumped++; |
| 11068 | } |
| 11069 | } |
| 11070 | } |
| 11071 | if (verbose) printf(" done\n"); |
| 11072 | cod_free_parse_context(context); |
| 11073 | cod_code_free(gen_code); |
| 11074 | } |
| 11075 | if ((only_run_test == NULL((void*)0)) || |
| 11076 | (strcmp(only_run_test, "c^i") == 0)) { |
| 11077 | int i, j; |
| 11078 | static char code[] = "{\n\ |
| 11079 | signed char a = p1;\n\ |
| 11080 | int b = p2;\n\ |
| 11081 | return a ^ b;\n\ |
| 11082 | }"; |
| 11083 | |
| 11084 | signed char (*proc)(signed char a, int b); |
| 11085 | cod_parse_context context = new_cod_parse_context(); |
| 11086 | int dumped = 0; |
| 11087 | |
| 11088 | cod_code gen_code; |
| 11089 | |
| 11090 | /* test for signed char ^ int */ |
| 11091 | if (verbose) printf("test for signed char ^ int"); |
| 11092 | |
| 11093 | cod_assoc_externs(context, externs); |
| 11094 | cod_parse_for_context(extern_string, context); |
| 11095 | |
| 11096 | cod_subroutine_declaration("signed char proc(signed char p1, int p2)", |
| 11097 | context); |
| 11098 | gen_code = cod_code_gen(code, context); |
| 11099 | proc = (signed char (*)(signed char, int))(long)gen_code->func; |
| 11100 | |
| 11101 | |
| 11102 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 11103 | signed char source1_c = src1c_vals[i]; |
| 11104 | for (j=0 ; j < sizeof(src2i_vals)/sizeof(src2i_vals[0]) ; j++) { |
| 11105 | int source2_i = src2i_vals[j]; |
| 11106 | |
| 11107 | signed char expected_result; |
| 11108 | signed char result; |
| 11109 | |
| 11110 | |
| 11111 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 11112 | |
| 11113 | expected_result = (signed char) (source1_c ^ source2_i); |
| 11114 | |
| 11115 | result = proc(source1_c, source2_i); |
| 11116 | if (expected_result != result) { |
| 11117 | printf("Failed signed char ^ int test, expected %d, got %d, for %d ^ %d\n", |
| 11118 | expected_result, result, source1_c, source2_i); |
| 11119 | if (dumped == 0) cod_dump(gen_code); |
| 11120 | failed++; |
| 11121 | dumped++; |
| 11122 | } |
| 11123 | } |
| 11124 | } |
| 11125 | if (verbose) printf(" done\n"); |
| 11126 | cod_free_parse_context(context); |
| 11127 | cod_code_free(gen_code); |
| 11128 | } |
| 11129 | if ((only_run_test == NULL((void*)0)) || |
| 11130 | (strcmp(only_run_test, "c^u") == 0)) { |
| 11131 | int i, j; |
| 11132 | static char code[] = "{\n\ |
| 11133 | signed char a = p1;\n\ |
| 11134 | unsigned int b = p2;\n\ |
| 11135 | return a ^ b;\n\ |
| 11136 | }"; |
| 11137 | |
| 11138 | signed char (*proc)(signed char a, unsigned int b); |
| 11139 | cod_parse_context context = new_cod_parse_context(); |
| 11140 | int dumped = 0; |
| 11141 | |
| 11142 | cod_code gen_code; |
| 11143 | |
| 11144 | /* test for signed char ^ unsigned int */ |
| 11145 | if (verbose) printf("test for signed char ^ unsigned int"); |
| 11146 | |
| 11147 | cod_assoc_externs(context, externs); |
| 11148 | cod_parse_for_context(extern_string, context); |
| 11149 | |
| 11150 | cod_subroutine_declaration("signed char proc(signed char p1, unsigned int p2)", |
| 11151 | context); |
| 11152 | gen_code = cod_code_gen(code, context); |
| 11153 | proc = (signed char (*)(signed char, unsigned int))(long)gen_code->func; |
| 11154 | |
| 11155 | |
| 11156 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 11157 | signed char source1_c = src1c_vals[i]; |
| 11158 | for (j=0 ; j < sizeof(src2u_vals)/sizeof(src2u_vals[0]) ; j++) { |
| 11159 | unsigned int source2_u = src2u_vals[j]; |
| 11160 | |
| 11161 | signed char expected_result; |
| 11162 | signed char result; |
| 11163 | |
| 11164 | |
| 11165 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 11166 | |
| 11167 | expected_result = (signed char) (source1_c ^ source2_u); |
| 11168 | |
| 11169 | result = proc(source1_c, source2_u); |
| 11170 | if (expected_result != result) { |
| 11171 | printf("Failed signed char ^ unsigned int test, expected %d, got %d, for %d ^ %u\n", |
| 11172 | expected_result, result, source1_c, source2_u); |
| 11173 | if (dumped == 0) cod_dump(gen_code); |
| 11174 | failed++; |
| 11175 | dumped++; |
| 11176 | } |
| 11177 | } |
| 11178 | } |
| 11179 | if (verbose) printf(" done\n"); |
| 11180 | cod_free_parse_context(context); |
| 11181 | cod_code_free(gen_code); |
| 11182 | } |
| 11183 | if ((only_run_test == NULL((void*)0)) || |
| 11184 | (strcmp(only_run_test, "c^ul") == 0)) { |
| 11185 | int i, j; |
| 11186 | static char code[] = "{\n\ |
| 11187 | signed char a = p1;\n\ |
| 11188 | unsigned long b = p2;\n\ |
| 11189 | return a ^ b;\n\ |
| 11190 | }"; |
| 11191 | |
| 11192 | signed char (*proc)(signed char a, unsigned long b); |
| 11193 | cod_parse_context context = new_cod_parse_context(); |
| 11194 | int dumped = 0; |
| 11195 | |
| 11196 | cod_code gen_code; |
| 11197 | |
| 11198 | /* test for signed char ^ unsigned long */ |
| 11199 | if (verbose) printf("test for signed char ^ unsigned long"); |
| 11200 | |
| 11201 | cod_assoc_externs(context, externs); |
| 11202 | cod_parse_for_context(extern_string, context); |
| 11203 | |
| 11204 | cod_subroutine_declaration("signed char proc(signed char p1, unsigned long p2)", |
| 11205 | context); |
| 11206 | gen_code = cod_code_gen(code, context); |
| 11207 | proc = (signed char (*)(signed char, unsigned long))(long)gen_code->func; |
| 11208 | |
| 11209 | |
| 11210 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 11211 | signed char source1_c = src1c_vals[i]; |
| 11212 | for (j=0 ; j < sizeof(src2ul_vals)/sizeof(src2ul_vals[0]) ; j++) { |
| 11213 | unsigned long source2_ul = src2ul_vals[j]; |
| 11214 | |
| 11215 | signed char expected_result; |
| 11216 | signed char result; |
| 11217 | |
| 11218 | |
| 11219 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 11220 | |
| 11221 | expected_result = (signed char) (source1_c ^ source2_ul); |
| 11222 | |
| 11223 | result = proc(source1_c, source2_ul); |
| 11224 | if (expected_result != result) { |
| 11225 | printf("Failed signed char ^ unsigned long test, expected %d, got %d, for %d ^ %lu\n", |
| 11226 | expected_result, result, source1_c, source2_ul); |
| 11227 | if (dumped == 0) cod_dump(gen_code); |
| 11228 | failed++; |
| 11229 | dumped++; |
| 11230 | } |
| 11231 | } |
| 11232 | } |
| 11233 | if (verbose) printf(" done\n"); |
| 11234 | cod_free_parse_context(context); |
| 11235 | cod_code_free(gen_code); |
| 11236 | } |
| 11237 | if ((only_run_test == NULL((void*)0)) || |
| 11238 | (strcmp(only_run_test, "c^l") == 0)) { |
| 11239 | int i, j; |
| 11240 | static char code[] = "{\n\ |
| 11241 | signed char a = p1;\n\ |
| 11242 | long b = p2;\n\ |
| 11243 | return a ^ b;\n\ |
| 11244 | }"; |
| 11245 | |
| 11246 | signed char (*proc)(signed char a, long b); |
| 11247 | cod_parse_context context = new_cod_parse_context(); |
| 11248 | int dumped = 0; |
| 11249 | |
| 11250 | cod_code gen_code; |
| 11251 | |
| 11252 | /* test for signed char ^ long */ |
| 11253 | if (verbose) printf("test for signed char ^ long"); |
| 11254 | |
| 11255 | cod_assoc_externs(context, externs); |
| 11256 | cod_parse_for_context(extern_string, context); |
| 11257 | |
| 11258 | cod_subroutine_declaration("signed char proc(signed char p1, long p2)", |
| 11259 | context); |
| 11260 | gen_code = cod_code_gen(code, context); |
| 11261 | proc = (signed char (*)(signed char, long))(long)gen_code->func; |
| 11262 | |
| 11263 | |
| 11264 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 11265 | signed char source1_c = src1c_vals[i]; |
| 11266 | for (j=0 ; j < sizeof(src2l_vals)/sizeof(src2l_vals[0]) ; j++) { |
| 11267 | long source2_l = src2l_vals[j]; |
| 11268 | |
| 11269 | signed char expected_result; |
| 11270 | signed char result; |
| 11271 | |
| 11272 | |
| 11273 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 11274 | |
| 11275 | expected_result = (signed char) (source1_c ^ source2_l); |
| 11276 | |
| 11277 | result = proc(source1_c, source2_l); |
| 11278 | if (expected_result != result) { |
| 11279 | printf("Failed signed char ^ long test, expected %d, got %d, for %d ^ %ld\n", |
| 11280 | expected_result, result, source1_c, source2_l); |
| 11281 | if (dumped == 0) cod_dump(gen_code); |
| 11282 | failed++; |
| 11283 | dumped++; |
| 11284 | } |
| 11285 | } |
| 11286 | } |
| 11287 | if (verbose) printf(" done\n"); |
| 11288 | cod_free_parse_context(context); |
| 11289 | cod_code_free(gen_code); |
| 11290 | } |
| 11291 | } |
| 11292 | void not_uc_tests() |
| 11293 | { |
| 11294 | if ((only_run_test == NULL((void*)0)) || |
| 11295 | (strcmp(only_run_test, "uc^c") == 0)) { |
| 11296 | int i, j; |
| 11297 | static char code[] = "{\n\ |
| 11298 | unsigned char a = p1;\n\ |
| 11299 | signed char b = p2;\n\ |
| 11300 | return a ^ b;\n\ |
| 11301 | }"; |
| 11302 | |
| 11303 | unsigned char (*proc)(unsigned char a, signed char b); |
| 11304 | cod_parse_context context = new_cod_parse_context(); |
| 11305 | int dumped = 0; |
| 11306 | |
| 11307 | cod_code gen_code; |
| 11308 | |
| 11309 | /* test for unsigned char ^ signed char */ |
| 11310 | if (verbose) printf("test for unsigned char ^ signed char"); |
| 11311 | |
| 11312 | cod_assoc_externs(context, externs); |
| 11313 | cod_parse_for_context(extern_string, context); |
| 11314 | |
| 11315 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, signed char p2)", |
| 11316 | context); |
| 11317 | gen_code = cod_code_gen(code, context); |
| 11318 | proc = (unsigned char (*)(unsigned char, signed char))(long)gen_code->func; |
| 11319 | |
| 11320 | |
| 11321 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 11322 | unsigned char source1_uc = src1uc_vals[i]; |
| 11323 | for (j=0 ; j < sizeof(src2c_vals)/sizeof(src2c_vals[0]) ; j++) { |
| 11324 | signed char source2_c = src2c_vals[j]; |
| 11325 | |
| 11326 | unsigned char expected_result; |
| 11327 | unsigned char result; |
| 11328 | |
| 11329 | |
| 11330 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 11331 | |
| 11332 | expected_result = (unsigned char) (source1_uc ^ source2_c); |
| 11333 | |
| 11334 | result = proc(source1_uc, source2_c); |
| 11335 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 11336 | if (expected_result != result) { |
| 11337 | printf("Failed unsigned char ^ signed char test, expected %u, got %u, for %u ^ %d\n", |
| 11338 | expected_result, result, source1_uc, source2_c); |
| 11339 | if (dumped == 0) cod_dump(gen_code); |
| 11340 | failed++; |
| 11341 | dumped++; |
| 11342 | } |
| 11343 | } |
| 11344 | } |
| 11345 | if (verbose) printf(" done\n"); |
| 11346 | cod_free_parse_context(context); |
| 11347 | cod_code_free(gen_code); |
| 11348 | } |
| 11349 | if ((only_run_test == NULL((void*)0)) || |
| 11350 | (strcmp(only_run_test, "uc^uc") == 0)) { |
| 11351 | int i, j; |
| 11352 | static char code[] = "{\n\ |
| 11353 | unsigned char a = p1;\n\ |
| 11354 | unsigned char b = p2;\n\ |
| 11355 | return a ^ b;\n\ |
| 11356 | }"; |
| 11357 | |
| 11358 | unsigned char (*proc)(unsigned char a, unsigned char b); |
| 11359 | cod_parse_context context = new_cod_parse_context(); |
| 11360 | int dumped = 0; |
| 11361 | |
| 11362 | cod_code gen_code; |
| 11363 | |
| 11364 | /* test for unsigned char ^ unsigned char */ |
| 11365 | if (verbose) printf("test for unsigned char ^ unsigned char"); |
| 11366 | |
| 11367 | cod_assoc_externs(context, externs); |
| 11368 | cod_parse_for_context(extern_string, context); |
| 11369 | |
| 11370 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, unsigned char p2)", |
| 11371 | context); |
| 11372 | gen_code = cod_code_gen(code, context); |
| 11373 | proc = (unsigned char (*)(unsigned char, unsigned char))(long)gen_code->func; |
| 11374 | |
| 11375 | |
| 11376 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 11377 | unsigned char source1_uc = src1uc_vals[i]; |
| 11378 | for (j=0 ; j < sizeof(src2uc_vals)/sizeof(src2uc_vals[0]) ; j++) { |
| 11379 | unsigned char source2_uc = src2uc_vals[j]; |
| 11380 | |
| 11381 | unsigned char expected_result; |
| 11382 | unsigned char result; |
| 11383 | |
| 11384 | |
| 11385 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 11386 | |
| 11387 | expected_result = (unsigned char) (source1_uc ^ source2_uc); |
| 11388 | |
| 11389 | result = proc(source1_uc, source2_uc); |
| 11390 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 11391 | if (expected_result != result) { |
| 11392 | printf("Failed unsigned char ^ unsigned char test, expected %u, got %u, for %u ^ %u\n", |
| 11393 | expected_result, result, source1_uc, source2_uc); |
| 11394 | if (dumped == 0) cod_dump(gen_code); |
| 11395 | failed++; |
| 11396 | dumped++; |
| 11397 | } |
| 11398 | } |
| 11399 | } |
| 11400 | if (verbose) printf(" done\n"); |
| 11401 | cod_free_parse_context(context); |
| 11402 | cod_code_free(gen_code); |
| 11403 | } |
| 11404 | if ((only_run_test == NULL((void*)0)) || |
| 11405 | (strcmp(only_run_test, "uc^s") == 0)) { |
| 11406 | int i, j; |
| 11407 | static char code[] = "{\n\ |
| 11408 | unsigned char a = p1;\n\ |
| 11409 | short b = p2;\n\ |
| 11410 | return a ^ b;\n\ |
| 11411 | }"; |
| 11412 | |
| 11413 | unsigned char (*proc)(unsigned char a, short b); |
| 11414 | cod_parse_context context = new_cod_parse_context(); |
| 11415 | int dumped = 0; |
| 11416 | |
| 11417 | cod_code gen_code; |
| 11418 | |
| 11419 | /* test for unsigned char ^ short */ |
| 11420 | if (verbose) printf("test for unsigned char ^ short"); |
| 11421 | |
| 11422 | cod_assoc_externs(context, externs); |
| 11423 | cod_parse_for_context(extern_string, context); |
| 11424 | |
| 11425 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, short p2)", |
| 11426 | context); |
| 11427 | gen_code = cod_code_gen(code, context); |
| 11428 | proc = (unsigned char (*)(unsigned char, short))(long)gen_code->func; |
| 11429 | |
| 11430 | |
| 11431 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 11432 | unsigned char source1_uc = src1uc_vals[i]; |
| 11433 | for (j=0 ; j < sizeof(src2s_vals)/sizeof(src2s_vals[0]) ; j++) { |
| 11434 | short source2_s = src2s_vals[j]; |
| 11435 | |
| 11436 | unsigned char expected_result; |
| 11437 | unsigned char result; |
| 11438 | |
| 11439 | |
| 11440 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 11441 | |
| 11442 | expected_result = (unsigned char) (source1_uc ^ source2_s); |
| 11443 | |
| 11444 | result = proc(source1_uc, source2_s); |
| 11445 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 11446 | if (expected_result != result) { |
| 11447 | printf("Failed unsigned char ^ short test, expected %u, got %u, for %u ^ %d\n", |
| 11448 | expected_result, result, source1_uc, source2_s); |
| 11449 | if (dumped == 0) cod_dump(gen_code); |
| 11450 | failed++; |
| 11451 | dumped++; |
| 11452 | } |
| 11453 | } |
| 11454 | } |
| 11455 | if (verbose) printf(" done\n"); |
| 11456 | cod_free_parse_context(context); |
| 11457 | cod_code_free(gen_code); |
| 11458 | } |
| 11459 | if ((only_run_test == NULL((void*)0)) || |
| 11460 | (strcmp(only_run_test, "uc^us") == 0)) { |
| 11461 | int i, j; |
| 11462 | static char code[] = "{\n\ |
| 11463 | unsigned char a = p1;\n\ |
| 11464 | unsigned short b = p2;\n\ |
| 11465 | return a ^ b;\n\ |
| 11466 | }"; |
| 11467 | |
| 11468 | unsigned char (*proc)(unsigned char a, unsigned short b); |
| 11469 | cod_parse_context context = new_cod_parse_context(); |
| 11470 | int dumped = 0; |
| 11471 | |
| 11472 | cod_code gen_code; |
| 11473 | |
| 11474 | /* test for unsigned char ^ unsigned short */ |
| 11475 | if (verbose) printf("test for unsigned char ^ unsigned short"); |
| 11476 | |
| 11477 | cod_assoc_externs(context, externs); |
| 11478 | cod_parse_for_context(extern_string, context); |
| 11479 | |
| 11480 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, unsigned short p2)", |
| 11481 | context); |
| 11482 | gen_code = cod_code_gen(code, context); |
| 11483 | proc = (unsigned char (*)(unsigned char, unsigned short))(long)gen_code->func; |
| 11484 | |
| 11485 | |
| 11486 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 11487 | unsigned char source1_uc = src1uc_vals[i]; |
| 11488 | for (j=0 ; j < sizeof(src2us_vals)/sizeof(src2us_vals[0]) ; j++) { |
| 11489 | unsigned short source2_us = src2us_vals[j]; |
| 11490 | |
| 11491 | unsigned char expected_result; |
| 11492 | unsigned char result; |
| 11493 | |
| 11494 | |
| 11495 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 11496 | |
| 11497 | expected_result = (unsigned char) (source1_uc ^ source2_us); |
| 11498 | |
| 11499 | result = proc(source1_uc, source2_us); |
| 11500 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 11501 | if (expected_result != result) { |
| 11502 | printf("Failed unsigned char ^ unsigned short test, expected %u, got %u, for %u ^ %u\n", |
| 11503 | expected_result, result, source1_uc, source2_us); |
| 11504 | if (dumped == 0) cod_dump(gen_code); |
| 11505 | failed++; |
| 11506 | dumped++; |
| 11507 | } |
| 11508 | } |
| 11509 | } |
| 11510 | if (verbose) printf(" done\n"); |
| 11511 | cod_free_parse_context(context); |
| 11512 | cod_code_free(gen_code); |
| 11513 | } |
| 11514 | if ((only_run_test == NULL((void*)0)) || |
| 11515 | (strcmp(only_run_test, "uc^i") == 0)) { |
| 11516 | int i, j; |
| 11517 | static char code[] = "{\n\ |
| 11518 | unsigned char a = p1;\n\ |
| 11519 | int b = p2;\n\ |
| 11520 | return a ^ b;\n\ |
| 11521 | }"; |
| 11522 | |
| 11523 | unsigned char (*proc)(unsigned char a, int b); |
| 11524 | cod_parse_context context = new_cod_parse_context(); |
| 11525 | int dumped = 0; |
| 11526 | |
| 11527 | cod_code gen_code; |
| 11528 | |
| 11529 | /* test for unsigned char ^ int */ |
| 11530 | if (verbose) printf("test for unsigned char ^ int"); |
| 11531 | |
| 11532 | cod_assoc_externs(context, externs); |
| 11533 | cod_parse_for_context(extern_string, context); |
| 11534 | |
| 11535 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, int p2)", |
| 11536 | context); |
| 11537 | gen_code = cod_code_gen(code, context); |
| 11538 | proc = (unsigned char (*)(unsigned char, int))(long)gen_code->func; |
| 11539 | |
| 11540 | |
| 11541 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 11542 | unsigned char source1_uc = src1uc_vals[i]; |
| 11543 | for (j=0 ; j < sizeof(src2i_vals)/sizeof(src2i_vals[0]) ; j++) { |
| 11544 | int source2_i = src2i_vals[j]; |
| 11545 | |
| 11546 | unsigned char expected_result; |
| 11547 | unsigned char result; |
| 11548 | |
| 11549 | |
| 11550 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 11551 | |
| 11552 | expected_result = (unsigned char) (source1_uc ^ source2_i); |
| 11553 | |
| 11554 | result = proc(source1_uc, source2_i); |
| 11555 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 11556 | if (expected_result != result) { |
| 11557 | printf("Failed unsigned char ^ int test, expected %u, got %u, for %u ^ %d\n", |
| 11558 | expected_result, result, source1_uc, source2_i); |
| 11559 | if (dumped == 0) cod_dump(gen_code); |
| 11560 | failed++; |
| 11561 | dumped++; |
| 11562 | } |
| 11563 | } |
| 11564 | } |
| 11565 | if (verbose) printf(" done\n"); |
| 11566 | cod_free_parse_context(context); |
| 11567 | cod_code_free(gen_code); |
| 11568 | } |
| 11569 | if ((only_run_test == NULL((void*)0)) || |
| 11570 | (strcmp(only_run_test, "uc^u") == 0)) { |
| 11571 | int i, j; |
| 11572 | static char code[] = "{\n\ |
| 11573 | unsigned char a = p1;\n\ |
| 11574 | unsigned int b = p2;\n\ |
| 11575 | return a ^ b;\n\ |
| 11576 | }"; |
| 11577 | |
| 11578 | unsigned char (*proc)(unsigned char a, unsigned int b); |
| 11579 | cod_parse_context context = new_cod_parse_context(); |
| 11580 | int dumped = 0; |
| 11581 | |
| 11582 | cod_code gen_code; |
| 11583 | |
| 11584 | /* test for unsigned char ^ unsigned int */ |
| 11585 | if (verbose) printf("test for unsigned char ^ unsigned int"); |
| 11586 | |
| 11587 | cod_assoc_externs(context, externs); |
| 11588 | cod_parse_for_context(extern_string, context); |
| 11589 | |
| 11590 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, unsigned int p2)", |
| 11591 | context); |
| 11592 | gen_code = cod_code_gen(code, context); |
| 11593 | proc = (unsigned char (*)(unsigned char, unsigned int))(long)gen_code->func; |
| 11594 | |
| 11595 | |
| 11596 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 11597 | unsigned char source1_uc = src1uc_vals[i]; |
| 11598 | for (j=0 ; j < sizeof(src2u_vals)/sizeof(src2u_vals[0]) ; j++) { |
| 11599 | unsigned int source2_u = src2u_vals[j]; |
| 11600 | |
| 11601 | unsigned char expected_result; |
| 11602 | unsigned char result; |
| 11603 | |
| 11604 | |
| 11605 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 11606 | |
| 11607 | expected_result = (unsigned char) (source1_uc ^ source2_u); |
| 11608 | |
| 11609 | result = proc(source1_uc, source2_u); |
| 11610 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 11611 | if (expected_result != result) { |
| 11612 | printf("Failed unsigned char ^ unsigned int test, expected %u, got %u, for %u ^ %u\n", |
| 11613 | expected_result, result, source1_uc, source2_u); |
| 11614 | if (dumped == 0) cod_dump(gen_code); |
| 11615 | failed++; |
| 11616 | dumped++; |
| 11617 | } |
| 11618 | } |
| 11619 | } |
| 11620 | if (verbose) printf(" done\n"); |
| 11621 | cod_free_parse_context(context); |
| 11622 | cod_code_free(gen_code); |
| 11623 | } |
| 11624 | if ((only_run_test == NULL((void*)0)) || |
| 11625 | (strcmp(only_run_test, "uc^ul") == 0)) { |
| 11626 | int i, j; |
| 11627 | static char code[] = "{\n\ |
| 11628 | unsigned char a = p1;\n\ |
| 11629 | unsigned long b = p2;\n\ |
| 11630 | return a ^ b;\n\ |
| 11631 | }"; |
| 11632 | |
| 11633 | unsigned char (*proc)(unsigned char a, unsigned long b); |
| 11634 | cod_parse_context context = new_cod_parse_context(); |
| 11635 | int dumped = 0; |
| 11636 | |
| 11637 | cod_code gen_code; |
| 11638 | |
| 11639 | /* test for unsigned char ^ unsigned long */ |
| 11640 | if (verbose) printf("test for unsigned char ^ unsigned long"); |
| 11641 | |
| 11642 | cod_assoc_externs(context, externs); |
| 11643 | cod_parse_for_context(extern_string, context); |
| 11644 | |
| 11645 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, unsigned long p2)", |
| 11646 | context); |
| 11647 | gen_code = cod_code_gen(code, context); |
| 11648 | proc = (unsigned char (*)(unsigned char, unsigned long))(long)gen_code->func; |
| 11649 | |
| 11650 | |
| 11651 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 11652 | unsigned char source1_uc = src1uc_vals[i]; |
| 11653 | for (j=0 ; j < sizeof(src2ul_vals)/sizeof(src2ul_vals[0]) ; j++) { |
| 11654 | unsigned long source2_ul = src2ul_vals[j]; |
| 11655 | |
| 11656 | unsigned char expected_result; |
| 11657 | unsigned char result; |
| 11658 | |
| 11659 | |
| 11660 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 11661 | |
| 11662 | expected_result = (unsigned char) (source1_uc ^ source2_ul); |
| 11663 | |
| 11664 | result = proc(source1_uc, source2_ul); |
| 11665 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 11666 | if (expected_result != result) { |
| 11667 | printf("Failed unsigned char ^ unsigned long test, expected %u, got %u, for %u ^ %lu\n", |
| 11668 | expected_result, result, source1_uc, source2_ul); |
| 11669 | if (dumped == 0) cod_dump(gen_code); |
| 11670 | failed++; |
| 11671 | dumped++; |
| 11672 | } |
| 11673 | } |
| 11674 | } |
| 11675 | if (verbose) printf(" done\n"); |
| 11676 | cod_free_parse_context(context); |
| 11677 | cod_code_free(gen_code); |
| 11678 | } |
| 11679 | if ((only_run_test == NULL((void*)0)) || |
| 11680 | (strcmp(only_run_test, "uc^l") == 0)) { |
| 11681 | int i, j; |
| 11682 | static char code[] = "{\n\ |
| 11683 | unsigned char a = p1;\n\ |
| 11684 | long b = p2;\n\ |
| 11685 | return a ^ b;\n\ |
| 11686 | }"; |
| 11687 | |
| 11688 | unsigned char (*proc)(unsigned char a, long b); |
| 11689 | cod_parse_context context = new_cod_parse_context(); |
| 11690 | int dumped = 0; |
| 11691 | |
| 11692 | cod_code gen_code; |
| 11693 | |
| 11694 | /* test for unsigned char ^ long */ |
| 11695 | if (verbose) printf("test for unsigned char ^ long"); |
| 11696 | |
| 11697 | cod_assoc_externs(context, externs); |
| 11698 | cod_parse_for_context(extern_string, context); |
| 11699 | |
| 11700 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, long p2)", |
| 11701 | context); |
| 11702 | gen_code = cod_code_gen(code, context); |
| 11703 | proc = (unsigned char (*)(unsigned char, long))(long)gen_code->func; |
| 11704 | |
| 11705 | |
| 11706 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 11707 | unsigned char source1_uc = src1uc_vals[i]; |
| 11708 | for (j=0 ; j < sizeof(src2l_vals)/sizeof(src2l_vals[0]) ; j++) { |
| 11709 | long source2_l = src2l_vals[j]; |
| 11710 | |
| 11711 | unsigned char expected_result; |
| 11712 | unsigned char result; |
| 11713 | |
| 11714 | |
| 11715 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 11716 | |
| 11717 | expected_result = (unsigned char) (source1_uc ^ source2_l); |
| 11718 | |
| 11719 | result = proc(source1_uc, source2_l); |
| 11720 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 11721 | if (expected_result != result) { |
| 11722 | printf("Failed unsigned char ^ long test, expected %u, got %u, for %u ^ %ld\n", |
| 11723 | expected_result, result, source1_uc, source2_l); |
| 11724 | if (dumped == 0) cod_dump(gen_code); |
| 11725 | failed++; |
| 11726 | dumped++; |
| 11727 | } |
| 11728 | } |
| 11729 | } |
| 11730 | if (verbose) printf(" done\n"); |
| 11731 | cod_free_parse_context(context); |
| 11732 | cod_code_free(gen_code); |
| 11733 | } |
| 11734 | } |
| 11735 | void not_s_tests() |
| 11736 | { |
| 11737 | if ((only_run_test == NULL((void*)0)) || |
| 11738 | (strcmp(only_run_test, "s^c") == 0)) { |
| 11739 | int i, j; |
| 11740 | static char code[] = "{\n\ |
| 11741 | short a = p1;\n\ |
| 11742 | signed char b = p2;\n\ |
| 11743 | return a ^ b;\n\ |
| 11744 | }"; |
| 11745 | |
| 11746 | short (*proc)(short a, signed char b); |
| 11747 | cod_parse_context context = new_cod_parse_context(); |
| 11748 | int dumped = 0; |
| 11749 | |
| 11750 | cod_code gen_code; |
| 11751 | |
| 11752 | /* test for short ^ signed char */ |
| 11753 | if (verbose) printf("test for short ^ signed char"); |
| 11754 | |
| 11755 | cod_assoc_externs(context, externs); |
| 11756 | cod_parse_for_context(extern_string, context); |
| 11757 | |
| 11758 | cod_subroutine_declaration("short proc(short p1, signed char p2)", |
| 11759 | context); |
| 11760 | gen_code = cod_code_gen(code, context); |
| 11761 | proc = (short (*)(short, signed char))(long)gen_code->func; |
| 11762 | |
| 11763 | |
| 11764 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 11765 | short source1_s = src1s_vals[i]; |
| 11766 | for (j=0 ; j < sizeof(src2c_vals)/sizeof(src2c_vals[0]) ; j++) { |
| 11767 | signed char source2_c = src2c_vals[j]; |
| 11768 | |
| 11769 | short expected_result; |
| 11770 | short result; |
| 11771 | |
| 11772 | |
| 11773 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 11774 | |
| 11775 | expected_result = (short) (source1_s ^ source2_c); |
| 11776 | |
| 11777 | result = proc(source1_s, source2_c); |
| 11778 | if (expected_result != result) { |
| 11779 | printf("Failed short ^ signed char test, expected %d, got %d, for %d ^ %d\n", |
| 11780 | expected_result, result, source1_s, source2_c); |
| 11781 | if (dumped == 0) cod_dump(gen_code); |
| 11782 | failed++; |
| 11783 | dumped++; |
| 11784 | } |
| 11785 | } |
| 11786 | } |
| 11787 | if (verbose) printf(" done\n"); |
| 11788 | cod_free_parse_context(context); |
| 11789 | cod_code_free(gen_code); |
| 11790 | } |
| 11791 | if ((only_run_test == NULL((void*)0)) || |
| 11792 | (strcmp(only_run_test, "s^uc") == 0)) { |
| 11793 | int i, j; |
| 11794 | static char code[] = "{\n\ |
| 11795 | short a = p1;\n\ |
| 11796 | unsigned char b = p2;\n\ |
| 11797 | return a ^ b;\n\ |
| 11798 | }"; |
| 11799 | |
| 11800 | short (*proc)(short a, unsigned char b); |
| 11801 | cod_parse_context context = new_cod_parse_context(); |
| 11802 | int dumped = 0; |
| 11803 | |
| 11804 | cod_code gen_code; |
| 11805 | |
| 11806 | /* test for short ^ unsigned char */ |
| 11807 | if (verbose) printf("test for short ^ unsigned char"); |
| 11808 | |
| 11809 | cod_assoc_externs(context, externs); |
| 11810 | cod_parse_for_context(extern_string, context); |
| 11811 | |
| 11812 | cod_subroutine_declaration("short proc(short p1, unsigned char p2)", |
| 11813 | context); |
| 11814 | gen_code = cod_code_gen(code, context); |
| 11815 | proc = (short (*)(short, unsigned char))(long)gen_code->func; |
| 11816 | |
| 11817 | |
| 11818 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 11819 | short source1_s = src1s_vals[i]; |
| 11820 | for (j=0 ; j < sizeof(src2uc_vals)/sizeof(src2uc_vals[0]) ; j++) { |
| 11821 | unsigned char source2_uc = src2uc_vals[j]; |
| 11822 | |
| 11823 | short expected_result; |
| 11824 | short result; |
| 11825 | |
| 11826 | |
| 11827 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 11828 | |
| 11829 | expected_result = (short) (source1_s ^ source2_uc); |
| 11830 | |
| 11831 | result = proc(source1_s, source2_uc); |
| 11832 | if (expected_result != result) { |
| 11833 | printf("Failed short ^ unsigned char test, expected %d, got %d, for %d ^ %u\n", |
| 11834 | expected_result, result, source1_s, source2_uc); |
| 11835 | if (dumped == 0) cod_dump(gen_code); |
| 11836 | failed++; |
| 11837 | dumped++; |
| 11838 | } |
| 11839 | } |
| 11840 | } |
| 11841 | if (verbose) printf(" done\n"); |
| 11842 | cod_free_parse_context(context); |
| 11843 | cod_code_free(gen_code); |
| 11844 | } |
| 11845 | if ((only_run_test == NULL((void*)0)) || |
| 11846 | (strcmp(only_run_test, "s^s") == 0)) { |
| 11847 | int i, j; |
| 11848 | static char code[] = "{\n\ |
| 11849 | short a = p1;\n\ |
| 11850 | short b = p2;\n\ |
| 11851 | return a ^ b;\n\ |
| 11852 | }"; |
| 11853 | |
| 11854 | short (*proc)(short a, short b); |
| 11855 | cod_parse_context context = new_cod_parse_context(); |
| 11856 | int dumped = 0; |
| 11857 | |
| 11858 | cod_code gen_code; |
| 11859 | |
| 11860 | /* test for short ^ short */ |
| 11861 | if (verbose) printf("test for short ^ short"); |
| 11862 | |
| 11863 | cod_assoc_externs(context, externs); |
| 11864 | cod_parse_for_context(extern_string, context); |
| 11865 | |
| 11866 | cod_subroutine_declaration("short proc(short p1, short p2)", |
| 11867 | context); |
| 11868 | gen_code = cod_code_gen(code, context); |
| 11869 | proc = (short (*)(short, short))(long)gen_code->func; |
| 11870 | |
| 11871 | |
| 11872 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 11873 | short source1_s = src1s_vals[i]; |
| 11874 | for (j=0 ; j < sizeof(src2s_vals)/sizeof(src2s_vals[0]) ; j++) { |
| 11875 | short source2_s = src2s_vals[j]; |
| 11876 | |
| 11877 | short expected_result; |
| 11878 | short result; |
| 11879 | |
| 11880 | |
| 11881 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 11882 | |
| 11883 | expected_result = (short) (source1_s ^ source2_s); |
| 11884 | |
| 11885 | result = proc(source1_s, source2_s); |
| 11886 | if (expected_result != result) { |
| 11887 | printf("Failed short ^ short test, expected %d, got %d, for %d ^ %d\n", |
| 11888 | expected_result, result, source1_s, source2_s); |
| 11889 | if (dumped == 0) cod_dump(gen_code); |
| 11890 | failed++; |
| 11891 | dumped++; |
| 11892 | } |
| 11893 | } |
| 11894 | } |
| 11895 | if (verbose) printf(" done\n"); |
| 11896 | cod_free_parse_context(context); |
| 11897 | cod_code_free(gen_code); |
| 11898 | } |
| 11899 | if ((only_run_test == NULL((void*)0)) || |
| 11900 | (strcmp(only_run_test, "s^us") == 0)) { |
| 11901 | int i, j; |
| 11902 | static char code[] = "{\n\ |
| 11903 | short a = p1;\n\ |
| 11904 | unsigned short b = p2;\n\ |
| 11905 | return a ^ b;\n\ |
| 11906 | }"; |
| 11907 | |
| 11908 | short (*proc)(short a, unsigned short b); |
| 11909 | cod_parse_context context = new_cod_parse_context(); |
| 11910 | int dumped = 0; |
| 11911 | |
| 11912 | cod_code gen_code; |
| 11913 | |
| 11914 | /* test for short ^ unsigned short */ |
| 11915 | if (verbose) printf("test for short ^ unsigned short"); |
| 11916 | |
| 11917 | cod_assoc_externs(context, externs); |
| 11918 | cod_parse_for_context(extern_string, context); |
| 11919 | |
| 11920 | cod_subroutine_declaration("short proc(short p1, unsigned short p2)", |
| 11921 | context); |
| 11922 | gen_code = cod_code_gen(code, context); |
| 11923 | proc = (short (*)(short, unsigned short))(long)gen_code->func; |
| 11924 | |
| 11925 | |
| 11926 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 11927 | short source1_s = src1s_vals[i]; |
| 11928 | for (j=0 ; j < sizeof(src2us_vals)/sizeof(src2us_vals[0]) ; j++) { |
| 11929 | unsigned short source2_us = src2us_vals[j]; |
| 11930 | |
| 11931 | short expected_result; |
| 11932 | short result; |
| 11933 | |
| 11934 | |
| 11935 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 11936 | |
| 11937 | expected_result = (short) (source1_s ^ source2_us); |
| 11938 | |
| 11939 | result = proc(source1_s, source2_us); |
| 11940 | if (expected_result != result) { |
| 11941 | printf("Failed short ^ unsigned short test, expected %d, got %d, for %d ^ %u\n", |
| 11942 | expected_result, result, source1_s, source2_us); |
| 11943 | if (dumped == 0) cod_dump(gen_code); |
| 11944 | failed++; |
| 11945 | dumped++; |
| 11946 | } |
| 11947 | } |
| 11948 | } |
| 11949 | if (verbose) printf(" done\n"); |
| 11950 | cod_free_parse_context(context); |
| 11951 | cod_code_free(gen_code); |
| 11952 | } |
| 11953 | if ((only_run_test == NULL((void*)0)) || |
| 11954 | (strcmp(only_run_test, "s^i") == 0)) { |
| 11955 | int i, j; |
| 11956 | static char code[] = "{\n\ |
| 11957 | short a = p1;\n\ |
| 11958 | int b = p2;\n\ |
| 11959 | return a ^ b;\n\ |
| 11960 | }"; |
| 11961 | |
| 11962 | short (*proc)(short a, int b); |
| 11963 | cod_parse_context context = new_cod_parse_context(); |
| 11964 | int dumped = 0; |
| 11965 | |
| 11966 | cod_code gen_code; |
| 11967 | |
| 11968 | /* test for short ^ int */ |
| 11969 | if (verbose) printf("test for short ^ int"); |
| 11970 | |
| 11971 | cod_assoc_externs(context, externs); |
| 11972 | cod_parse_for_context(extern_string, context); |
| 11973 | |
| 11974 | cod_subroutine_declaration("short proc(short p1, int p2)", |
| 11975 | context); |
| 11976 | gen_code = cod_code_gen(code, context); |
| 11977 | proc = (short (*)(short, int))(long)gen_code->func; |
| 11978 | |
| 11979 | |
| 11980 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 11981 | short source1_s = src1s_vals[i]; |
| 11982 | for (j=0 ; j < sizeof(src2i_vals)/sizeof(src2i_vals[0]) ; j++) { |
| 11983 | int source2_i = src2i_vals[j]; |
| 11984 | |
| 11985 | short expected_result; |
| 11986 | short result; |
| 11987 | |
| 11988 | |
| 11989 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 11990 | |
| 11991 | expected_result = (short) (source1_s ^ source2_i); |
| 11992 | |
| 11993 | result = proc(source1_s, source2_i); |
| 11994 | if (expected_result != result) { |
| 11995 | printf("Failed short ^ int test, expected %d, got %d, for %d ^ %d\n", |
| 11996 | expected_result, result, source1_s, source2_i); |
| 11997 | if (dumped == 0) cod_dump(gen_code); |
| 11998 | failed++; |
| 11999 | dumped++; |
| 12000 | } |
| 12001 | } |
| 12002 | } |
| 12003 | if (verbose) printf(" done\n"); |
| 12004 | cod_free_parse_context(context); |
| 12005 | cod_code_free(gen_code); |
| 12006 | } |
| 12007 | if ((only_run_test == NULL((void*)0)) || |
| 12008 | (strcmp(only_run_test, "s^u") == 0)) { |
| 12009 | int i, j; |
| 12010 | static char code[] = "{\n\ |
| 12011 | short a = p1;\n\ |
| 12012 | unsigned int b = p2;\n\ |
| 12013 | return a ^ b;\n\ |
| 12014 | }"; |
| 12015 | |
| 12016 | short (*proc)(short a, unsigned int b); |
| 12017 | cod_parse_context context = new_cod_parse_context(); |
| 12018 | int dumped = 0; |
| 12019 | |
| 12020 | cod_code gen_code; |
| 12021 | |
| 12022 | /* test for short ^ unsigned int */ |
| 12023 | if (verbose) printf("test for short ^ unsigned int"); |
| 12024 | |
| 12025 | cod_assoc_externs(context, externs); |
| 12026 | cod_parse_for_context(extern_string, context); |
| 12027 | |
| 12028 | cod_subroutine_declaration("short proc(short p1, unsigned int p2)", |
| 12029 | context); |
| 12030 | gen_code = cod_code_gen(code, context); |
| 12031 | proc = (short (*)(short, unsigned int))(long)gen_code->func; |
| 12032 | |
| 12033 | |
| 12034 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 12035 | short source1_s = src1s_vals[i]; |
| 12036 | for (j=0 ; j < sizeof(src2u_vals)/sizeof(src2u_vals[0]) ; j++) { |
| 12037 | unsigned int source2_u = src2u_vals[j]; |
| 12038 | |
| 12039 | short expected_result; |
| 12040 | short result; |
| 12041 | |
| 12042 | |
| 12043 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 12044 | |
| 12045 | expected_result = (short) (source1_s ^ source2_u); |
| 12046 | |
| 12047 | result = proc(source1_s, source2_u); |
| 12048 | if (expected_result != result) { |
| 12049 | printf("Failed short ^ unsigned int test, expected %d, got %d, for %d ^ %u\n", |
| 12050 | expected_result, result, source1_s, source2_u); |
| 12051 | if (dumped == 0) cod_dump(gen_code); |
| 12052 | failed++; |
| 12053 | dumped++; |
| 12054 | } |
| 12055 | } |
| 12056 | } |
| 12057 | if (verbose) printf(" done\n"); |
| 12058 | cod_free_parse_context(context); |
| 12059 | cod_code_free(gen_code); |
| 12060 | } |
| 12061 | if ((only_run_test == NULL((void*)0)) || |
| 12062 | (strcmp(only_run_test, "s^ul") == 0)) { |
| 12063 | int i, j; |
| 12064 | static char code[] = "{\n\ |
| 12065 | short a = p1;\n\ |
| 12066 | unsigned long b = p2;\n\ |
| 12067 | return a ^ b;\n\ |
| 12068 | }"; |
| 12069 | |
| 12070 | short (*proc)(short a, unsigned long b); |
| 12071 | cod_parse_context context = new_cod_parse_context(); |
| 12072 | int dumped = 0; |
| 12073 | |
| 12074 | cod_code gen_code; |
| 12075 | |
| 12076 | /* test for short ^ unsigned long */ |
| 12077 | if (verbose) printf("test for short ^ unsigned long"); |
| 12078 | |
| 12079 | cod_assoc_externs(context, externs); |
| 12080 | cod_parse_for_context(extern_string, context); |
| 12081 | |
| 12082 | cod_subroutine_declaration("short proc(short p1, unsigned long p2)", |
| 12083 | context); |
| 12084 | gen_code = cod_code_gen(code, context); |
| 12085 | proc = (short (*)(short, unsigned long))(long)gen_code->func; |
| 12086 | |
| 12087 | |
| 12088 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 12089 | short source1_s = src1s_vals[i]; |
| 12090 | for (j=0 ; j < sizeof(src2ul_vals)/sizeof(src2ul_vals[0]) ; j++) { |
| 12091 | unsigned long source2_ul = src2ul_vals[j]; |
| 12092 | |
| 12093 | short expected_result; |
| 12094 | short result; |
| 12095 | |
| 12096 | |
| 12097 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 12098 | |
| 12099 | expected_result = (short) (source1_s ^ source2_ul); |
| 12100 | |
| 12101 | result = proc(source1_s, source2_ul); |
| 12102 | if (expected_result != result) { |
| 12103 | printf("Failed short ^ unsigned long test, expected %d, got %d, for %d ^ %lu\n", |
| 12104 | expected_result, result, source1_s, source2_ul); |
| 12105 | if (dumped == 0) cod_dump(gen_code); |
| 12106 | failed++; |
| 12107 | dumped++; |
| 12108 | } |
| 12109 | } |
| 12110 | } |
| 12111 | if (verbose) printf(" done\n"); |
| 12112 | cod_free_parse_context(context); |
| 12113 | cod_code_free(gen_code); |
| 12114 | } |
| 12115 | if ((only_run_test == NULL((void*)0)) || |
| 12116 | (strcmp(only_run_test, "s^l") == 0)) { |
| 12117 | int i, j; |
| 12118 | static char code[] = "{\n\ |
| 12119 | short a = p1;\n\ |
| 12120 | long b = p2;\n\ |
| 12121 | return a ^ b;\n\ |
| 12122 | }"; |
| 12123 | |
| 12124 | short (*proc)(short a, long b); |
| 12125 | cod_parse_context context = new_cod_parse_context(); |
| 12126 | int dumped = 0; |
| 12127 | |
| 12128 | cod_code gen_code; |
| 12129 | |
| 12130 | /* test for short ^ long */ |
| 12131 | if (verbose) printf("test for short ^ long"); |
| 12132 | |
| 12133 | cod_assoc_externs(context, externs); |
| 12134 | cod_parse_for_context(extern_string, context); |
| 12135 | |
| 12136 | cod_subroutine_declaration("short proc(short p1, long p2)", |
| 12137 | context); |
| 12138 | gen_code = cod_code_gen(code, context); |
| 12139 | proc = (short (*)(short, long))(long)gen_code->func; |
| 12140 | |
| 12141 | |
| 12142 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 12143 | short source1_s = src1s_vals[i]; |
| 12144 | for (j=0 ; j < sizeof(src2l_vals)/sizeof(src2l_vals[0]) ; j++) { |
| 12145 | long source2_l = src2l_vals[j]; |
| 12146 | |
| 12147 | short expected_result; |
| 12148 | short result; |
| 12149 | |
| 12150 | |
| 12151 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 12152 | |
| 12153 | expected_result = (short) (source1_s ^ source2_l); |
| 12154 | |
| 12155 | result = proc(source1_s, source2_l); |
| 12156 | if (expected_result != result) { |
| 12157 | printf("Failed short ^ long test, expected %d, got %d, for %d ^ %ld\n", |
| 12158 | expected_result, result, source1_s, source2_l); |
| 12159 | if (dumped == 0) cod_dump(gen_code); |
| 12160 | failed++; |
| 12161 | dumped++; |
| 12162 | } |
| 12163 | } |
| 12164 | } |
| 12165 | if (verbose) printf(" done\n"); |
| 12166 | cod_free_parse_context(context); |
| 12167 | cod_code_free(gen_code); |
| 12168 | } |
| 12169 | } |
| 12170 | void not_us_tests() |
| 12171 | { |
| 12172 | if ((only_run_test == NULL((void*)0)) || |
| 12173 | (strcmp(only_run_test, "us^c") == 0)) { |
| 12174 | int i, j; |
| 12175 | static char code[] = "{\n\ |
| 12176 | unsigned short a = p1;\n\ |
| 12177 | signed char b = p2;\n\ |
| 12178 | return a ^ b;\n\ |
| 12179 | }"; |
| 12180 | |
| 12181 | unsigned short (*proc)(unsigned short a, signed char b); |
| 12182 | cod_parse_context context = new_cod_parse_context(); |
| 12183 | int dumped = 0; |
| 12184 | |
| 12185 | cod_code gen_code; |
| 12186 | |
| 12187 | /* test for unsigned short ^ signed char */ |
| 12188 | if (verbose) printf("test for unsigned short ^ signed char"); |
| 12189 | |
| 12190 | cod_assoc_externs(context, externs); |
| 12191 | cod_parse_for_context(extern_string, context); |
| 12192 | |
| 12193 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, signed char p2)", |
| 12194 | context); |
| 12195 | gen_code = cod_code_gen(code, context); |
| 12196 | proc = (unsigned short (*)(unsigned short, signed char))(long)gen_code->func; |
| 12197 | |
| 12198 | |
| 12199 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 12200 | unsigned short source1_us = src1us_vals[i]; |
| 12201 | for (j=0 ; j < sizeof(src2c_vals)/sizeof(src2c_vals[0]) ; j++) { |
| 12202 | signed char source2_c = src2c_vals[j]; |
| 12203 | |
| 12204 | unsigned short expected_result; |
| 12205 | unsigned short result; |
| 12206 | |
| 12207 | |
| 12208 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 12209 | |
| 12210 | expected_result = (unsigned short) (source1_us ^ source2_c); |
| 12211 | |
| 12212 | result = proc(source1_us, source2_c); |
| 12213 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 12214 | if (expected_result != result) { |
| 12215 | printf("Failed unsigned short ^ signed char test, expected %u, got %u, for %u ^ %d\n", |
| 12216 | expected_result, result, source1_us, source2_c); |
| 12217 | if (dumped == 0) cod_dump(gen_code); |
| 12218 | failed++; |
| 12219 | dumped++; |
| 12220 | } |
| 12221 | } |
| 12222 | } |
| 12223 | if (verbose) printf(" done\n"); |
| 12224 | cod_free_parse_context(context); |
| 12225 | cod_code_free(gen_code); |
| 12226 | } |
| 12227 | if ((only_run_test == NULL((void*)0)) || |
| 12228 | (strcmp(only_run_test, "us^uc") == 0)) { |
| 12229 | int i, j; |
| 12230 | static char code[] = "{\n\ |
| 12231 | unsigned short a = p1;\n\ |
| 12232 | unsigned char b = p2;\n\ |
| 12233 | return a ^ b;\n\ |
| 12234 | }"; |
| 12235 | |
| 12236 | unsigned short (*proc)(unsigned short a, unsigned char b); |
| 12237 | cod_parse_context context = new_cod_parse_context(); |
| 12238 | int dumped = 0; |
| 12239 | |
| 12240 | cod_code gen_code; |
| 12241 | |
| 12242 | /* test for unsigned short ^ unsigned char */ |
| 12243 | if (verbose) printf("test for unsigned short ^ unsigned char"); |
| 12244 | |
| 12245 | cod_assoc_externs(context, externs); |
| 12246 | cod_parse_for_context(extern_string, context); |
| 12247 | |
| 12248 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, unsigned char p2)", |
| 12249 | context); |
| 12250 | gen_code = cod_code_gen(code, context); |
| 12251 | proc = (unsigned short (*)(unsigned short, unsigned char))(long)gen_code->func; |
| 12252 | |
| 12253 | |
| 12254 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 12255 | unsigned short source1_us = src1us_vals[i]; |
| 12256 | for (j=0 ; j < sizeof(src2uc_vals)/sizeof(src2uc_vals[0]) ; j++) { |
| 12257 | unsigned char source2_uc = src2uc_vals[j]; |
| 12258 | |
| 12259 | unsigned short expected_result; |
| 12260 | unsigned short result; |
| 12261 | |
| 12262 | |
| 12263 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 12264 | |
| 12265 | expected_result = (unsigned short) (source1_us ^ source2_uc); |
| 12266 | |
| 12267 | result = proc(source1_us, source2_uc); |
| 12268 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 12269 | if (expected_result != result) { |
| 12270 | printf("Failed unsigned short ^ unsigned char test, expected %u, got %u, for %u ^ %u\n", |
| 12271 | expected_result, result, source1_us, source2_uc); |
| 12272 | if (dumped == 0) cod_dump(gen_code); |
| 12273 | failed++; |
| 12274 | dumped++; |
| 12275 | } |
| 12276 | } |
| 12277 | } |
| 12278 | if (verbose) printf(" done\n"); |
| 12279 | cod_free_parse_context(context); |
| 12280 | cod_code_free(gen_code); |
| 12281 | } |
| 12282 | if ((only_run_test == NULL((void*)0)) || |
| 12283 | (strcmp(only_run_test, "us^s") == 0)) { |
| 12284 | int i, j; |
| 12285 | static char code[] = "{\n\ |
| 12286 | unsigned short a = p1;\n\ |
| 12287 | short b = p2;\n\ |
| 12288 | return a ^ b;\n\ |
| 12289 | }"; |
| 12290 | |
| 12291 | unsigned short (*proc)(unsigned short a, short b); |
| 12292 | cod_parse_context context = new_cod_parse_context(); |
| 12293 | int dumped = 0; |
| 12294 | |
| 12295 | cod_code gen_code; |
| 12296 | |
| 12297 | /* test for unsigned short ^ short */ |
| 12298 | if (verbose) printf("test for unsigned short ^ short"); |
| 12299 | |
| 12300 | cod_assoc_externs(context, externs); |
| 12301 | cod_parse_for_context(extern_string, context); |
| 12302 | |
| 12303 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, short p2)", |
| 12304 | context); |
| 12305 | gen_code = cod_code_gen(code, context); |
| 12306 | proc = (unsigned short (*)(unsigned short, short))(long)gen_code->func; |
| 12307 | |
| 12308 | |
| 12309 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 12310 | unsigned short source1_us = src1us_vals[i]; |
| 12311 | for (j=0 ; j < sizeof(src2s_vals)/sizeof(src2s_vals[0]) ; j++) { |
| 12312 | short source2_s = src2s_vals[j]; |
| 12313 | |
| 12314 | unsigned short expected_result; |
| 12315 | unsigned short result; |
| 12316 | |
| 12317 | |
| 12318 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 12319 | |
| 12320 | expected_result = (unsigned short) (source1_us ^ source2_s); |
| 12321 | |
| 12322 | result = proc(source1_us, source2_s); |
| 12323 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 12324 | if (expected_result != result) { |
| 12325 | printf("Failed unsigned short ^ short test, expected %u, got %u, for %u ^ %d\n", |
| 12326 | expected_result, result, source1_us, source2_s); |
| 12327 | if (dumped == 0) cod_dump(gen_code); |
| 12328 | failed++; |
| 12329 | dumped++; |
| 12330 | } |
| 12331 | } |
| 12332 | } |
| 12333 | if (verbose) printf(" done\n"); |
| 12334 | cod_free_parse_context(context); |
| 12335 | cod_code_free(gen_code); |
| 12336 | } |
| 12337 | if ((only_run_test == NULL((void*)0)) || |
| 12338 | (strcmp(only_run_test, "us^us") == 0)) { |
| 12339 | int i, j; |
| 12340 | static char code[] = "{\n\ |
| 12341 | unsigned short a = p1;\n\ |
| 12342 | unsigned short b = p2;\n\ |
| 12343 | return a ^ b;\n\ |
| 12344 | }"; |
| 12345 | |
| 12346 | unsigned short (*proc)(unsigned short a, unsigned short b); |
| 12347 | cod_parse_context context = new_cod_parse_context(); |
| 12348 | int dumped = 0; |
| 12349 | |
| 12350 | cod_code gen_code; |
| 12351 | |
| 12352 | /* test for unsigned short ^ unsigned short */ |
| 12353 | if (verbose) printf("test for unsigned short ^ unsigned short"); |
| 12354 | |
| 12355 | cod_assoc_externs(context, externs); |
| 12356 | cod_parse_for_context(extern_string, context); |
| 12357 | |
| 12358 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, unsigned short p2)", |
| 12359 | context); |
| 12360 | gen_code = cod_code_gen(code, context); |
| 12361 | proc = (unsigned short (*)(unsigned short, unsigned short))(long)gen_code->func; |
| 12362 | |
| 12363 | |
| 12364 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 12365 | unsigned short source1_us = src1us_vals[i]; |
| 12366 | for (j=0 ; j < sizeof(src2us_vals)/sizeof(src2us_vals[0]) ; j++) { |
| 12367 | unsigned short source2_us = src2us_vals[j]; |
| 12368 | |
| 12369 | unsigned short expected_result; |
| 12370 | unsigned short result; |
| 12371 | |
| 12372 | |
| 12373 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 12374 | |
| 12375 | expected_result = (unsigned short) (source1_us ^ source2_us); |
| 12376 | |
| 12377 | result = proc(source1_us, source2_us); |
| 12378 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 12379 | if (expected_result != result) { |
| 12380 | printf("Failed unsigned short ^ unsigned short test, expected %u, got %u, for %u ^ %u\n", |
| 12381 | expected_result, result, source1_us, source2_us); |
| 12382 | if (dumped == 0) cod_dump(gen_code); |
| 12383 | failed++; |
| 12384 | dumped++; |
| 12385 | } |
| 12386 | } |
| 12387 | } |
| 12388 | if (verbose) printf(" done\n"); |
| 12389 | cod_free_parse_context(context); |
| 12390 | cod_code_free(gen_code); |
| 12391 | } |
| 12392 | if ((only_run_test == NULL((void*)0)) || |
| 12393 | (strcmp(only_run_test, "us^i") == 0)) { |
| 12394 | int i, j; |
| 12395 | static char code[] = "{\n\ |
| 12396 | unsigned short a = p1;\n\ |
| 12397 | int b = p2;\n\ |
| 12398 | return a ^ b;\n\ |
| 12399 | }"; |
| 12400 | |
| 12401 | unsigned short (*proc)(unsigned short a, int b); |
| 12402 | cod_parse_context context = new_cod_parse_context(); |
| 12403 | int dumped = 0; |
| 12404 | |
| 12405 | cod_code gen_code; |
| 12406 | |
| 12407 | /* test for unsigned short ^ int */ |
| 12408 | if (verbose) printf("test for unsigned short ^ int"); |
| 12409 | |
| 12410 | cod_assoc_externs(context, externs); |
| 12411 | cod_parse_for_context(extern_string, context); |
| 12412 | |
| 12413 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, int p2)", |
| 12414 | context); |
| 12415 | gen_code = cod_code_gen(code, context); |
| 12416 | proc = (unsigned short (*)(unsigned short, int))(long)gen_code->func; |
| 12417 | |
| 12418 | |
| 12419 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 12420 | unsigned short source1_us = src1us_vals[i]; |
| 12421 | for (j=0 ; j < sizeof(src2i_vals)/sizeof(src2i_vals[0]) ; j++) { |
| 12422 | int source2_i = src2i_vals[j]; |
| 12423 | |
| 12424 | unsigned short expected_result; |
| 12425 | unsigned short result; |
| 12426 | |
| 12427 | |
| 12428 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 12429 | |
| 12430 | expected_result = (unsigned short) (source1_us ^ source2_i); |
| 12431 | |
| 12432 | result = proc(source1_us, source2_i); |
| 12433 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 12434 | if (expected_result != result) { |
| 12435 | printf("Failed unsigned short ^ int test, expected %u, got %u, for %u ^ %d\n", |
| 12436 | expected_result, result, source1_us, source2_i); |
| 12437 | if (dumped == 0) cod_dump(gen_code); |
| 12438 | failed++; |
| 12439 | dumped++; |
| 12440 | } |
| 12441 | } |
| 12442 | } |
| 12443 | if (verbose) printf(" done\n"); |
| 12444 | cod_free_parse_context(context); |
| 12445 | cod_code_free(gen_code); |
| 12446 | } |
| 12447 | if ((only_run_test == NULL((void*)0)) || |
| 12448 | (strcmp(only_run_test, "us^u") == 0)) { |
| 12449 | int i, j; |
| 12450 | static char code[] = "{\n\ |
| 12451 | unsigned short a = p1;\n\ |
| 12452 | unsigned int b = p2;\n\ |
| 12453 | return a ^ b;\n\ |
| 12454 | }"; |
| 12455 | |
| 12456 | unsigned short (*proc)(unsigned short a, unsigned int b); |
| 12457 | cod_parse_context context = new_cod_parse_context(); |
| 12458 | int dumped = 0; |
| 12459 | |
| 12460 | cod_code gen_code; |
| 12461 | |
| 12462 | /* test for unsigned short ^ unsigned int */ |
| 12463 | if (verbose) printf("test for unsigned short ^ unsigned int"); |
| 12464 | |
| 12465 | cod_assoc_externs(context, externs); |
| 12466 | cod_parse_for_context(extern_string, context); |
| 12467 | |
| 12468 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, unsigned int p2)", |
| 12469 | context); |
| 12470 | gen_code = cod_code_gen(code, context); |
| 12471 | proc = (unsigned short (*)(unsigned short, unsigned int))(long)gen_code->func; |
| 12472 | |
| 12473 | |
| 12474 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 12475 | unsigned short source1_us = src1us_vals[i]; |
| 12476 | for (j=0 ; j < sizeof(src2u_vals)/sizeof(src2u_vals[0]) ; j++) { |
| 12477 | unsigned int source2_u = src2u_vals[j]; |
| 12478 | |
| 12479 | unsigned short expected_result; |
| 12480 | unsigned short result; |
| 12481 | |
| 12482 | |
| 12483 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 12484 | |
| 12485 | expected_result = (unsigned short) (source1_us ^ source2_u); |
| 12486 | |
| 12487 | result = proc(source1_us, source2_u); |
| 12488 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 12489 | if (expected_result != result) { |
| 12490 | printf("Failed unsigned short ^ unsigned int test, expected %u, got %u, for %u ^ %u\n", |
| 12491 | expected_result, result, source1_us, source2_u); |
| 12492 | if (dumped == 0) cod_dump(gen_code); |
| 12493 | failed++; |
| 12494 | dumped++; |
| 12495 | } |
| 12496 | } |
| 12497 | } |
| 12498 | if (verbose) printf(" done\n"); |
| 12499 | cod_free_parse_context(context); |
| 12500 | cod_code_free(gen_code); |
| 12501 | } |
| 12502 | if ((only_run_test == NULL((void*)0)) || |
| 12503 | (strcmp(only_run_test, "us^ul") == 0)) { |
| 12504 | int i, j; |
| 12505 | static char code[] = "{\n\ |
| 12506 | unsigned short a = p1;\n\ |
| 12507 | unsigned long b = p2;\n\ |
| 12508 | return a ^ b;\n\ |
| 12509 | }"; |
| 12510 | |
| 12511 | unsigned short (*proc)(unsigned short a, unsigned long b); |
| 12512 | cod_parse_context context = new_cod_parse_context(); |
| 12513 | int dumped = 0; |
| 12514 | |
| 12515 | cod_code gen_code; |
| 12516 | |
| 12517 | /* test for unsigned short ^ unsigned long */ |
| 12518 | if (verbose) printf("test for unsigned short ^ unsigned long"); |
| 12519 | |
| 12520 | cod_assoc_externs(context, externs); |
| 12521 | cod_parse_for_context(extern_string, context); |
| 12522 | |
| 12523 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, unsigned long p2)", |
| 12524 | context); |
| 12525 | gen_code = cod_code_gen(code, context); |
| 12526 | proc = (unsigned short (*)(unsigned short, unsigned long))(long)gen_code->func; |
| 12527 | |
| 12528 | |
| 12529 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 12530 | unsigned short source1_us = src1us_vals[i]; |
| 12531 | for (j=0 ; j < sizeof(src2ul_vals)/sizeof(src2ul_vals[0]) ; j++) { |
| 12532 | unsigned long source2_ul = src2ul_vals[j]; |
| 12533 | |
| 12534 | unsigned short expected_result; |
| 12535 | unsigned short result; |
| 12536 | |
| 12537 | |
| 12538 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 12539 | |
| 12540 | expected_result = (unsigned short) (source1_us ^ source2_ul); |
| 12541 | |
| 12542 | result = proc(source1_us, source2_ul); |
| 12543 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 12544 | if (expected_result != result) { |
| 12545 | printf("Failed unsigned short ^ unsigned long test, expected %u, got %u, for %u ^ %lu\n", |
| 12546 | expected_result, result, source1_us, source2_ul); |
| 12547 | if (dumped == 0) cod_dump(gen_code); |
| 12548 | failed++; |
| 12549 | dumped++; |
| 12550 | } |
| 12551 | } |
| 12552 | } |
| 12553 | if (verbose) printf(" done\n"); |
| 12554 | cod_free_parse_context(context); |
| 12555 | cod_code_free(gen_code); |
| 12556 | } |
| 12557 | if ((only_run_test == NULL((void*)0)) || |
| 12558 | (strcmp(only_run_test, "us^l") == 0)) { |
| 12559 | int i, j; |
| 12560 | static char code[] = "{\n\ |
| 12561 | unsigned short a = p1;\n\ |
| 12562 | long b = p2;\n\ |
| 12563 | return a ^ b;\n\ |
| 12564 | }"; |
| 12565 | |
| 12566 | unsigned short (*proc)(unsigned short a, long b); |
| 12567 | cod_parse_context context = new_cod_parse_context(); |
| 12568 | int dumped = 0; |
| 12569 | |
| 12570 | cod_code gen_code; |
| 12571 | |
| 12572 | /* test for unsigned short ^ long */ |
| 12573 | if (verbose) printf("test for unsigned short ^ long"); |
| 12574 | |
| 12575 | cod_assoc_externs(context, externs); |
| 12576 | cod_parse_for_context(extern_string, context); |
| 12577 | |
| 12578 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, long p2)", |
| 12579 | context); |
| 12580 | gen_code = cod_code_gen(code, context); |
| 12581 | proc = (unsigned short (*)(unsigned short, long))(long)gen_code->func; |
| 12582 | |
| 12583 | |
| 12584 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 12585 | unsigned short source1_us = src1us_vals[i]; |
| 12586 | for (j=0 ; j < sizeof(src2l_vals)/sizeof(src2l_vals[0]) ; j++) { |
| 12587 | long source2_l = src2l_vals[j]; |
| 12588 | |
| 12589 | unsigned short expected_result; |
| 12590 | unsigned short result; |
| 12591 | |
| 12592 | |
| 12593 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 12594 | |
| 12595 | expected_result = (unsigned short) (source1_us ^ source2_l); |
| 12596 | |
| 12597 | result = proc(source1_us, source2_l); |
| 12598 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 12599 | if (expected_result != result) { |
| 12600 | printf("Failed unsigned short ^ long test, expected %u, got %u, for %u ^ %ld\n", |
| 12601 | expected_result, result, source1_us, source2_l); |
| 12602 | if (dumped == 0) cod_dump(gen_code); |
| 12603 | failed++; |
| 12604 | dumped++; |
| 12605 | } |
| 12606 | } |
| 12607 | } |
| 12608 | if (verbose) printf(" done\n"); |
| 12609 | cod_free_parse_context(context); |
| 12610 | cod_code_free(gen_code); |
| 12611 | } |
| 12612 | } |
| 12613 | void not_i_tests() |
| 12614 | { |
| 12615 | if ((only_run_test == NULL((void*)0)) || |
| 12616 | (strcmp(only_run_test, "i^c") == 0)) { |
| 12617 | int i, j; |
| 12618 | static char code[] = "{\n\ |
| 12619 | int a = p1;\n\ |
| 12620 | signed char b = p2;\n\ |
| 12621 | return a ^ b;\n\ |
| 12622 | }"; |
| 12623 | |
| 12624 | int (*proc)(int a, signed char b); |
| 12625 | cod_parse_context context = new_cod_parse_context(); |
| 12626 | int dumped = 0; |
| 12627 | |
| 12628 | cod_code gen_code; |
| 12629 | |
| 12630 | /* test for int ^ signed char */ |
| 12631 | if (verbose) printf("test for int ^ signed char"); |
| 12632 | |
| 12633 | cod_assoc_externs(context, externs); |
| 12634 | cod_parse_for_context(extern_string, context); |
| 12635 | |
| 12636 | cod_subroutine_declaration("int proc(int p1, signed char p2)", |
| 12637 | context); |
| 12638 | gen_code = cod_code_gen(code, context); |
| 12639 | proc = (int (*)(int, signed char))(long)gen_code->func; |
| 12640 | |
| 12641 | |
| 12642 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 12643 | int source1_i = src1i_vals[i]; |
| 12644 | for (j=0 ; j < sizeof(src2c_vals)/sizeof(src2c_vals[0]) ; j++) { |
| 12645 | signed char source2_c = src2c_vals[j]; |
| 12646 | |
| 12647 | int expected_result; |
| 12648 | int result; |
| 12649 | |
| 12650 | |
| 12651 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 12652 | |
| 12653 | expected_result = (int) (source1_i ^ source2_c); |
| 12654 | |
| 12655 | result = proc(source1_i, source2_c); |
| 12656 | if (expected_result != result) { |
| 12657 | printf("Failed int ^ signed char test, expected %d, got %d, for %d ^ %d\n", |
| 12658 | expected_result, result, source1_i, source2_c); |
| 12659 | if (dumped == 0) cod_dump(gen_code); |
| 12660 | failed++; |
| 12661 | dumped++; |
| 12662 | } |
| 12663 | } |
| 12664 | } |
| 12665 | if (verbose) printf(" done\n"); |
| 12666 | cod_free_parse_context(context); |
| 12667 | cod_code_free(gen_code); |
| 12668 | } |
| 12669 | if ((only_run_test == NULL((void*)0)) || |
| 12670 | (strcmp(only_run_test, "i^uc") == 0)) { |
| 12671 | int i, j; |
| 12672 | static char code[] = "{\n\ |
| 12673 | int a = p1;\n\ |
| 12674 | unsigned char b = p2;\n\ |
| 12675 | return a ^ b;\n\ |
| 12676 | }"; |
| 12677 | |
| 12678 | int (*proc)(int a, unsigned char b); |
| 12679 | cod_parse_context context = new_cod_parse_context(); |
| 12680 | int dumped = 0; |
| 12681 | |
| 12682 | cod_code gen_code; |
| 12683 | |
| 12684 | /* test for int ^ unsigned char */ |
| 12685 | if (verbose) printf("test for int ^ unsigned char"); |
| 12686 | |
| 12687 | cod_assoc_externs(context, externs); |
| 12688 | cod_parse_for_context(extern_string, context); |
| 12689 | |
| 12690 | cod_subroutine_declaration("int proc(int p1, unsigned char p2)", |
| 12691 | context); |
| 12692 | gen_code = cod_code_gen(code, context); |
| 12693 | proc = (int (*)(int, unsigned char))(long)gen_code->func; |
| 12694 | |
| 12695 | |
| 12696 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 12697 | int source1_i = src1i_vals[i]; |
| 12698 | for (j=0 ; j < sizeof(src2uc_vals)/sizeof(src2uc_vals[0]) ; j++) { |
| 12699 | unsigned char source2_uc = src2uc_vals[j]; |
| 12700 | |
| 12701 | int expected_result; |
| 12702 | int result; |
| 12703 | |
| 12704 | |
| 12705 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 12706 | |
| 12707 | expected_result = (int) (source1_i ^ source2_uc); |
| 12708 | |
| 12709 | result = proc(source1_i, source2_uc); |
| 12710 | if (expected_result != result) { |
| 12711 | printf("Failed int ^ unsigned char test, expected %d, got %d, for %d ^ %u\n", |
| 12712 | expected_result, result, source1_i, source2_uc); |
| 12713 | if (dumped == 0) cod_dump(gen_code); |
| 12714 | failed++; |
| 12715 | dumped++; |
| 12716 | } |
| 12717 | } |
| 12718 | } |
| 12719 | if (verbose) printf(" done\n"); |
| 12720 | cod_free_parse_context(context); |
| 12721 | cod_code_free(gen_code); |
| 12722 | } |
| 12723 | if ((only_run_test == NULL((void*)0)) || |
| 12724 | (strcmp(only_run_test, "i^s") == 0)) { |
| 12725 | int i, j; |
| 12726 | static char code[] = "{\n\ |
| 12727 | int a = p1;\n\ |
| 12728 | short b = p2;\n\ |
| 12729 | return a ^ b;\n\ |
| 12730 | }"; |
| 12731 | |
| 12732 | int (*proc)(int a, short b); |
| 12733 | cod_parse_context context = new_cod_parse_context(); |
| 12734 | int dumped = 0; |
| 12735 | |
| 12736 | cod_code gen_code; |
| 12737 | |
| 12738 | /* test for int ^ short */ |
| 12739 | if (verbose) printf("test for int ^ short"); |
| 12740 | |
| 12741 | cod_assoc_externs(context, externs); |
| 12742 | cod_parse_for_context(extern_string, context); |
| 12743 | |
| 12744 | cod_subroutine_declaration("int proc(int p1, short p2)", |
| 12745 | context); |
| 12746 | gen_code = cod_code_gen(code, context); |
| 12747 | proc = (int (*)(int, short))(long)gen_code->func; |
| 12748 | |
| 12749 | |
| 12750 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 12751 | int source1_i = src1i_vals[i]; |
| 12752 | for (j=0 ; j < sizeof(src2s_vals)/sizeof(src2s_vals[0]) ; j++) { |
| 12753 | short source2_s = src2s_vals[j]; |
| 12754 | |
| 12755 | int expected_result; |
| 12756 | int result; |
| 12757 | |
| 12758 | |
| 12759 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 12760 | |
| 12761 | expected_result = (int) (source1_i ^ source2_s); |
| 12762 | |
| 12763 | result = proc(source1_i, source2_s); |
| 12764 | if (expected_result != result) { |
| 12765 | printf("Failed int ^ short test, expected %d, got %d, for %d ^ %d\n", |
| 12766 | expected_result, result, source1_i, source2_s); |
| 12767 | if (dumped == 0) cod_dump(gen_code); |
| 12768 | failed++; |
| 12769 | dumped++; |
| 12770 | } |
| 12771 | } |
| 12772 | } |
| 12773 | if (verbose) printf(" done\n"); |
| 12774 | cod_free_parse_context(context); |
| 12775 | cod_code_free(gen_code); |
| 12776 | } |
| 12777 | if ((only_run_test == NULL((void*)0)) || |
| 12778 | (strcmp(only_run_test, "i^us") == 0)) { |
| 12779 | int i, j; |
| 12780 | static char code[] = "{\n\ |
| 12781 | int a = p1;\n\ |
| 12782 | unsigned short b = p2;\n\ |
| 12783 | return a ^ b;\n\ |
| 12784 | }"; |
| 12785 | |
| 12786 | int (*proc)(int a, unsigned short b); |
| 12787 | cod_parse_context context = new_cod_parse_context(); |
| 12788 | int dumped = 0; |
| 12789 | |
| 12790 | cod_code gen_code; |
| 12791 | |
| 12792 | /* test for int ^ unsigned short */ |
| 12793 | if (verbose) printf("test for int ^ unsigned short"); |
| 12794 | |
| 12795 | cod_assoc_externs(context, externs); |
| 12796 | cod_parse_for_context(extern_string, context); |
| 12797 | |
| 12798 | cod_subroutine_declaration("int proc(int p1, unsigned short p2)", |
| 12799 | context); |
| 12800 | gen_code = cod_code_gen(code, context); |
| 12801 | proc = (int (*)(int, unsigned short))(long)gen_code->func; |
| 12802 | |
| 12803 | |
| 12804 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 12805 | int source1_i = src1i_vals[i]; |
| 12806 | for (j=0 ; j < sizeof(src2us_vals)/sizeof(src2us_vals[0]) ; j++) { |
| 12807 | unsigned short source2_us = src2us_vals[j]; |
| 12808 | |
| 12809 | int expected_result; |
| 12810 | int result; |
| 12811 | |
| 12812 | |
| 12813 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 12814 | |
| 12815 | expected_result = (int) (source1_i ^ source2_us); |
| 12816 | |
| 12817 | result = proc(source1_i, source2_us); |
| 12818 | if (expected_result != result) { |
| 12819 | printf("Failed int ^ unsigned short test, expected %d, got %d, for %d ^ %u\n", |
| 12820 | expected_result, result, source1_i, source2_us); |
| 12821 | if (dumped == 0) cod_dump(gen_code); |
| 12822 | failed++; |
| 12823 | dumped++; |
| 12824 | } |
| 12825 | } |
| 12826 | } |
| 12827 | if (verbose) printf(" done\n"); |
| 12828 | cod_free_parse_context(context); |
| 12829 | cod_code_free(gen_code); |
| 12830 | } |
| 12831 | if ((only_run_test == NULL((void*)0)) || |
| 12832 | (strcmp(only_run_test, "i^i") == 0)) { |
| 12833 | int i, j; |
| 12834 | static char code[] = "{\n\ |
| 12835 | int a = p1;\n\ |
| 12836 | int b = p2;\n\ |
| 12837 | return a ^ b;\n\ |
| 12838 | }"; |
| 12839 | |
| 12840 | int (*proc)(int a, int b); |
| 12841 | cod_parse_context context = new_cod_parse_context(); |
| 12842 | int dumped = 0; |
| 12843 | |
| 12844 | cod_code gen_code; |
| 12845 | |
| 12846 | /* test for int ^ int */ |
| 12847 | if (verbose) printf("test for int ^ int"); |
| 12848 | |
| 12849 | cod_assoc_externs(context, externs); |
| 12850 | cod_parse_for_context(extern_string, context); |
| 12851 | |
| 12852 | cod_subroutine_declaration("int proc(int p1, int p2)", |
| 12853 | context); |
| 12854 | gen_code = cod_code_gen(code, context); |
| 12855 | proc = (int (*)(int, int))(long)gen_code->func; |
| 12856 | |
| 12857 | |
| 12858 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 12859 | int source1_i = src1i_vals[i]; |
| 12860 | for (j=0 ; j < sizeof(src2i_vals)/sizeof(src2i_vals[0]) ; j++) { |
| 12861 | int source2_i = src2i_vals[j]; |
| 12862 | |
| 12863 | int expected_result; |
| 12864 | int result; |
| 12865 | |
| 12866 | |
| 12867 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 12868 | |
| 12869 | expected_result = (int) (source1_i ^ source2_i); |
| 12870 | |
| 12871 | result = proc(source1_i, source2_i); |
| 12872 | if (expected_result != result) { |
| 12873 | printf("Failed int ^ int test, expected %d, got %d, for %d ^ %d\n", |
| 12874 | expected_result, result, source1_i, source2_i); |
| 12875 | if (dumped == 0) cod_dump(gen_code); |
| 12876 | failed++; |
| 12877 | dumped++; |
| 12878 | } |
| 12879 | } |
| 12880 | } |
| 12881 | if (verbose) printf(" done\n"); |
| 12882 | cod_free_parse_context(context); |
| 12883 | cod_code_free(gen_code); |
| 12884 | } |
| 12885 | if ((only_run_test == NULL((void*)0)) || |
| 12886 | (strcmp(only_run_test, "i^u") == 0)) { |
| 12887 | int i, j; |
| 12888 | static char code[] = "{\n\ |
| 12889 | int a = p1;\n\ |
| 12890 | unsigned int b = p2;\n\ |
| 12891 | return a ^ b;\n\ |
| 12892 | }"; |
| 12893 | |
| 12894 | int (*proc)(int a, unsigned int b); |
| 12895 | cod_parse_context context = new_cod_parse_context(); |
| 12896 | int dumped = 0; |
| 12897 | |
| 12898 | cod_code gen_code; |
| 12899 | |
| 12900 | /* test for int ^ unsigned int */ |
| 12901 | if (verbose) printf("test for int ^ unsigned int"); |
| 12902 | |
| 12903 | cod_assoc_externs(context, externs); |
| 12904 | cod_parse_for_context(extern_string, context); |
| 12905 | |
| 12906 | cod_subroutine_declaration("int proc(int p1, unsigned int p2)", |
| 12907 | context); |
| 12908 | gen_code = cod_code_gen(code, context); |
| 12909 | proc = (int (*)(int, unsigned int))(long)gen_code->func; |
| 12910 | |
| 12911 | |
| 12912 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 12913 | int source1_i = src1i_vals[i]; |
| 12914 | for (j=0 ; j < sizeof(src2u_vals)/sizeof(src2u_vals[0]) ; j++) { |
| 12915 | unsigned int source2_u = src2u_vals[j]; |
| 12916 | |
| 12917 | int expected_result; |
| 12918 | int result; |
| 12919 | |
| 12920 | |
| 12921 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 12922 | |
| 12923 | expected_result = (int) (source1_i ^ source2_u); |
| 12924 | |
| 12925 | result = proc(source1_i, source2_u); |
| 12926 | if (expected_result != result) { |
| 12927 | printf("Failed int ^ unsigned int test, expected %d, got %d, for %d ^ %u\n", |
| 12928 | expected_result, result, source1_i, source2_u); |
| 12929 | if (dumped == 0) cod_dump(gen_code); |
| 12930 | failed++; |
| 12931 | dumped++; |
| 12932 | } |
| 12933 | } |
| 12934 | } |
| 12935 | if (verbose) printf(" done\n"); |
| 12936 | cod_free_parse_context(context); |
| 12937 | cod_code_free(gen_code); |
| 12938 | } |
| 12939 | if ((only_run_test == NULL((void*)0)) || |
| 12940 | (strcmp(only_run_test, "i^ul") == 0)) { |
| 12941 | int i, j; |
| 12942 | static char code[] = "{\n\ |
| 12943 | int a = p1;\n\ |
| 12944 | unsigned long b = p2;\n\ |
| 12945 | return a ^ b;\n\ |
| 12946 | }"; |
| 12947 | |
| 12948 | int (*proc)(int a, unsigned long b); |
| 12949 | cod_parse_context context = new_cod_parse_context(); |
| 12950 | int dumped = 0; |
| 12951 | |
| 12952 | cod_code gen_code; |
| 12953 | |
| 12954 | /* test for int ^ unsigned long */ |
| 12955 | if (verbose) printf("test for int ^ unsigned long"); |
| 12956 | |
| 12957 | cod_assoc_externs(context, externs); |
| 12958 | cod_parse_for_context(extern_string, context); |
| 12959 | |
| 12960 | cod_subroutine_declaration("int proc(int p1, unsigned long p2)", |
| 12961 | context); |
| 12962 | gen_code = cod_code_gen(code, context); |
| 12963 | proc = (int (*)(int, unsigned long))(long)gen_code->func; |
| 12964 | |
| 12965 | |
| 12966 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 12967 | int source1_i = src1i_vals[i]; |
| 12968 | for (j=0 ; j < sizeof(src2ul_vals)/sizeof(src2ul_vals[0]) ; j++) { |
| 12969 | unsigned long source2_ul = src2ul_vals[j]; |
| 12970 | |
| 12971 | int expected_result; |
| 12972 | int result; |
| 12973 | |
| 12974 | |
| 12975 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 12976 | |
| 12977 | expected_result = (int) (source1_i ^ source2_ul); |
| 12978 | |
| 12979 | result = proc(source1_i, source2_ul); |
| 12980 | if (expected_result != result) { |
| 12981 | printf("Failed int ^ unsigned long test, expected %d, got %d, for %d ^ %lu\n", |
| 12982 | expected_result, result, source1_i, source2_ul); |
| 12983 | if (dumped == 0) cod_dump(gen_code); |
| 12984 | failed++; |
| 12985 | dumped++; |
| 12986 | } |
| 12987 | } |
| 12988 | } |
| 12989 | if (verbose) printf(" done\n"); |
| 12990 | cod_free_parse_context(context); |
| 12991 | cod_code_free(gen_code); |
| 12992 | } |
| 12993 | if ((only_run_test == NULL((void*)0)) || |
| 12994 | (strcmp(only_run_test, "i^l") == 0)) { |
| 12995 | int i, j; |
| 12996 | static char code[] = "{\n\ |
| 12997 | int a = p1;\n\ |
| 12998 | long b = p2;\n\ |
| 12999 | return a ^ b;\n\ |
| 13000 | }"; |
| 13001 | |
| 13002 | int (*proc)(int a, long b); |
| 13003 | cod_parse_context context = new_cod_parse_context(); |
| 13004 | int dumped = 0; |
| 13005 | |
| 13006 | cod_code gen_code; |
| 13007 | |
| 13008 | /* test for int ^ long */ |
| 13009 | if (verbose) printf("test for int ^ long"); |
| 13010 | |
| 13011 | cod_assoc_externs(context, externs); |
| 13012 | cod_parse_for_context(extern_string, context); |
| 13013 | |
| 13014 | cod_subroutine_declaration("int proc(int p1, long p2)", |
| 13015 | context); |
| 13016 | gen_code = cod_code_gen(code, context); |
| 13017 | proc = (int (*)(int, long))(long)gen_code->func; |
| 13018 | |
| 13019 | |
| 13020 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 13021 | int source1_i = src1i_vals[i]; |
| 13022 | for (j=0 ; j < sizeof(src2l_vals)/sizeof(src2l_vals[0]) ; j++) { |
| 13023 | long source2_l = src2l_vals[j]; |
| 13024 | |
| 13025 | int expected_result; |
| 13026 | int result; |
| 13027 | |
| 13028 | |
| 13029 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 13030 | |
| 13031 | expected_result = (int) (source1_i ^ source2_l); |
| 13032 | |
| 13033 | result = proc(source1_i, source2_l); |
| 13034 | if (expected_result != result) { |
| 13035 | printf("Failed int ^ long test, expected %d, got %d, for %d ^ %ld\n", |
| 13036 | expected_result, result, source1_i, source2_l); |
| 13037 | if (dumped == 0) cod_dump(gen_code); |
| 13038 | failed++; |
| 13039 | dumped++; |
| 13040 | } |
| 13041 | } |
| 13042 | } |
| 13043 | if (verbose) printf(" done\n"); |
| 13044 | cod_free_parse_context(context); |
| 13045 | cod_code_free(gen_code); |
| 13046 | } |
| 13047 | } |
| 13048 | void not_u_tests() |
| 13049 | { |
| 13050 | if ((only_run_test == NULL((void*)0)) || |
| 13051 | (strcmp(only_run_test, "u^c") == 0)) { |
| 13052 | int i, j; |
| 13053 | static char code[] = "{\n\ |
| 13054 | unsigned int a = p1;\n\ |
| 13055 | signed char b = p2;\n\ |
| 13056 | return a ^ b;\n\ |
| 13057 | }"; |
| 13058 | |
| 13059 | unsigned int (*proc)(unsigned int a, signed char b); |
| 13060 | cod_parse_context context = new_cod_parse_context(); |
| 13061 | int dumped = 0; |
| 13062 | |
| 13063 | cod_code gen_code; |
| 13064 | |
| 13065 | /* test for unsigned int ^ signed char */ |
| 13066 | if (verbose) printf("test for unsigned int ^ signed char"); |
| 13067 | |
| 13068 | cod_assoc_externs(context, externs); |
| 13069 | cod_parse_for_context(extern_string, context); |
| 13070 | |
| 13071 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, signed char p2)", |
| 13072 | context); |
| 13073 | gen_code = cod_code_gen(code, context); |
| 13074 | proc = (unsigned int (*)(unsigned int, signed char))(long)gen_code->func; |
| 13075 | |
| 13076 | |
| 13077 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 13078 | unsigned int source1_u = src1u_vals[i]; |
| 13079 | for (j=0 ; j < sizeof(src2c_vals)/sizeof(src2c_vals[0]) ; j++) { |
| 13080 | signed char source2_c = src2c_vals[j]; |
| 13081 | |
| 13082 | unsigned int expected_result; |
| 13083 | unsigned int result; |
| 13084 | |
| 13085 | |
| 13086 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 13087 | |
| 13088 | expected_result = (unsigned int) (source1_u ^ source2_c); |
| 13089 | |
| 13090 | result = proc(source1_u, source2_c); |
| 13091 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 13092 | if (expected_result != result) { |
| 13093 | printf("Failed unsigned int ^ signed char test, expected %u, got %u, for %u ^ %d\n", |
| 13094 | expected_result, result, source1_u, source2_c); |
| 13095 | if (dumped == 0) cod_dump(gen_code); |
| 13096 | failed++; |
| 13097 | dumped++; |
| 13098 | } |
| 13099 | } |
| 13100 | } |
| 13101 | if (verbose) printf(" done\n"); |
| 13102 | cod_free_parse_context(context); |
| 13103 | cod_code_free(gen_code); |
| 13104 | } |
| 13105 | if ((only_run_test == NULL((void*)0)) || |
| 13106 | (strcmp(only_run_test, "u^uc") == 0)) { |
| 13107 | int i, j; |
| 13108 | static char code[] = "{\n\ |
| 13109 | unsigned int a = p1;\n\ |
| 13110 | unsigned char b = p2;\n\ |
| 13111 | return a ^ b;\n\ |
| 13112 | }"; |
| 13113 | |
| 13114 | unsigned int (*proc)(unsigned int a, unsigned char b); |
| 13115 | cod_parse_context context = new_cod_parse_context(); |
| 13116 | int dumped = 0; |
| 13117 | |
| 13118 | cod_code gen_code; |
| 13119 | |
| 13120 | /* test for unsigned int ^ unsigned char */ |
| 13121 | if (verbose) printf("test for unsigned int ^ unsigned char"); |
| 13122 | |
| 13123 | cod_assoc_externs(context, externs); |
| 13124 | cod_parse_for_context(extern_string, context); |
| 13125 | |
| 13126 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, unsigned char p2)", |
| 13127 | context); |
| 13128 | gen_code = cod_code_gen(code, context); |
| 13129 | proc = (unsigned int (*)(unsigned int, unsigned char))(long)gen_code->func; |
| 13130 | |
| 13131 | |
| 13132 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 13133 | unsigned int source1_u = src1u_vals[i]; |
| 13134 | for (j=0 ; j < sizeof(src2uc_vals)/sizeof(src2uc_vals[0]) ; j++) { |
| 13135 | unsigned char source2_uc = src2uc_vals[j]; |
| 13136 | |
| 13137 | unsigned int expected_result; |
| 13138 | unsigned int result; |
| 13139 | |
| 13140 | |
| 13141 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 13142 | |
| 13143 | expected_result = (unsigned int) (source1_u ^ source2_uc); |
| 13144 | |
| 13145 | result = proc(source1_u, source2_uc); |
| 13146 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 13147 | if (expected_result != result) { |
| 13148 | printf("Failed unsigned int ^ unsigned char test, expected %u, got %u, for %u ^ %u\n", |
| 13149 | expected_result, result, source1_u, source2_uc); |
| 13150 | if (dumped == 0) cod_dump(gen_code); |
| 13151 | failed++; |
| 13152 | dumped++; |
| 13153 | } |
| 13154 | } |
| 13155 | } |
| 13156 | if (verbose) printf(" done\n"); |
| 13157 | cod_free_parse_context(context); |
| 13158 | cod_code_free(gen_code); |
| 13159 | } |
| 13160 | if ((only_run_test == NULL((void*)0)) || |
| 13161 | (strcmp(only_run_test, "u^s") == 0)) { |
| 13162 | int i, j; |
| 13163 | static char code[] = "{\n\ |
| 13164 | unsigned int a = p1;\n\ |
| 13165 | short b = p2;\n\ |
| 13166 | return a ^ b;\n\ |
| 13167 | }"; |
| 13168 | |
| 13169 | unsigned int (*proc)(unsigned int a, short b); |
| 13170 | cod_parse_context context = new_cod_parse_context(); |
| 13171 | int dumped = 0; |
| 13172 | |
| 13173 | cod_code gen_code; |
| 13174 | |
| 13175 | /* test for unsigned int ^ short */ |
| 13176 | if (verbose) printf("test for unsigned int ^ short"); |
| 13177 | |
| 13178 | cod_assoc_externs(context, externs); |
| 13179 | cod_parse_for_context(extern_string, context); |
| 13180 | |
| 13181 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, short p2)", |
| 13182 | context); |
| 13183 | gen_code = cod_code_gen(code, context); |
| 13184 | proc = (unsigned int (*)(unsigned int, short))(long)gen_code->func; |
| 13185 | |
| 13186 | |
| 13187 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 13188 | unsigned int source1_u = src1u_vals[i]; |
| 13189 | for (j=0 ; j < sizeof(src2s_vals)/sizeof(src2s_vals[0]) ; j++) { |
| 13190 | short source2_s = src2s_vals[j]; |
| 13191 | |
| 13192 | unsigned int expected_result; |
| 13193 | unsigned int result; |
| 13194 | |
| 13195 | |
| 13196 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 13197 | |
| 13198 | expected_result = (unsigned int) (source1_u ^ source2_s); |
| 13199 | |
| 13200 | result = proc(source1_u, source2_s); |
| 13201 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 13202 | if (expected_result != result) { |
| 13203 | printf("Failed unsigned int ^ short test, expected %u, got %u, for %u ^ %d\n", |
| 13204 | expected_result, result, source1_u, source2_s); |
| 13205 | if (dumped == 0) cod_dump(gen_code); |
| 13206 | failed++; |
| 13207 | dumped++; |
| 13208 | } |
| 13209 | } |
| 13210 | } |
| 13211 | if (verbose) printf(" done\n"); |
| 13212 | cod_free_parse_context(context); |
| 13213 | cod_code_free(gen_code); |
| 13214 | } |
| 13215 | if ((only_run_test == NULL((void*)0)) || |
| 13216 | (strcmp(only_run_test, "u^us") == 0)) { |
| 13217 | int i, j; |
| 13218 | static char code[] = "{\n\ |
| 13219 | unsigned int a = p1;\n\ |
| 13220 | unsigned short b = p2;\n\ |
| 13221 | return a ^ b;\n\ |
| 13222 | }"; |
| 13223 | |
| 13224 | unsigned int (*proc)(unsigned int a, unsigned short b); |
| 13225 | cod_parse_context context = new_cod_parse_context(); |
| 13226 | int dumped = 0; |
| 13227 | |
| 13228 | cod_code gen_code; |
| 13229 | |
| 13230 | /* test for unsigned int ^ unsigned short */ |
| 13231 | if (verbose) printf("test for unsigned int ^ unsigned short"); |
| 13232 | |
| 13233 | cod_assoc_externs(context, externs); |
| 13234 | cod_parse_for_context(extern_string, context); |
| 13235 | |
| 13236 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, unsigned short p2)", |
| 13237 | context); |
| 13238 | gen_code = cod_code_gen(code, context); |
| 13239 | proc = (unsigned int (*)(unsigned int, unsigned short))(long)gen_code->func; |
| 13240 | |
| 13241 | |
| 13242 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 13243 | unsigned int source1_u = src1u_vals[i]; |
| 13244 | for (j=0 ; j < sizeof(src2us_vals)/sizeof(src2us_vals[0]) ; j++) { |
| 13245 | unsigned short source2_us = src2us_vals[j]; |
| 13246 | |
| 13247 | unsigned int expected_result; |
| 13248 | unsigned int result; |
| 13249 | |
| 13250 | |
| 13251 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 13252 | |
| 13253 | expected_result = (unsigned int) (source1_u ^ source2_us); |
| 13254 | |
| 13255 | result = proc(source1_u, source2_us); |
| 13256 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 13257 | if (expected_result != result) { |
| 13258 | printf("Failed unsigned int ^ unsigned short test, expected %u, got %u, for %u ^ %u\n", |
| 13259 | expected_result, result, source1_u, source2_us); |
| 13260 | if (dumped == 0) cod_dump(gen_code); |
| 13261 | failed++; |
| 13262 | dumped++; |
| 13263 | } |
| 13264 | } |
| 13265 | } |
| 13266 | if (verbose) printf(" done\n"); |
| 13267 | cod_free_parse_context(context); |
| 13268 | cod_code_free(gen_code); |
| 13269 | } |
| 13270 | if ((only_run_test == NULL((void*)0)) || |
| 13271 | (strcmp(only_run_test, "u^i") == 0)) { |
| 13272 | int i, j; |
| 13273 | static char code[] = "{\n\ |
| 13274 | unsigned int a = p1;\n\ |
| 13275 | int b = p2;\n\ |
| 13276 | return a ^ b;\n\ |
| 13277 | }"; |
| 13278 | |
| 13279 | unsigned int (*proc)(unsigned int a, int b); |
| 13280 | cod_parse_context context = new_cod_parse_context(); |
| 13281 | int dumped = 0; |
| 13282 | |
| 13283 | cod_code gen_code; |
| 13284 | |
| 13285 | /* test for unsigned int ^ int */ |
| 13286 | if (verbose) printf("test for unsigned int ^ int"); |
| 13287 | |
| 13288 | cod_assoc_externs(context, externs); |
| 13289 | cod_parse_for_context(extern_string, context); |
| 13290 | |
| 13291 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, int p2)", |
| 13292 | context); |
| 13293 | gen_code = cod_code_gen(code, context); |
| 13294 | proc = (unsigned int (*)(unsigned int, int))(long)gen_code->func; |
| 13295 | |
| 13296 | |
| 13297 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 13298 | unsigned int source1_u = src1u_vals[i]; |
| 13299 | for (j=0 ; j < sizeof(src2i_vals)/sizeof(src2i_vals[0]) ; j++) { |
| 13300 | int source2_i = src2i_vals[j]; |
| 13301 | |
| 13302 | unsigned int expected_result; |
| 13303 | unsigned int result; |
| 13304 | |
| 13305 | |
| 13306 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 13307 | |
| 13308 | expected_result = (unsigned int) (source1_u ^ source2_i); |
| 13309 | |
| 13310 | result = proc(source1_u, source2_i); |
| 13311 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 13312 | if (expected_result != result) { |
| 13313 | printf("Failed unsigned int ^ int test, expected %u, got %u, for %u ^ %d\n", |
| 13314 | expected_result, result, source1_u, source2_i); |
| 13315 | if (dumped == 0) cod_dump(gen_code); |
| 13316 | failed++; |
| 13317 | dumped++; |
| 13318 | } |
| 13319 | } |
| 13320 | } |
| 13321 | if (verbose) printf(" done\n"); |
| 13322 | cod_free_parse_context(context); |
| 13323 | cod_code_free(gen_code); |
| 13324 | } |
| 13325 | if ((only_run_test == NULL((void*)0)) || |
| 13326 | (strcmp(only_run_test, "u^u") == 0)) { |
| 13327 | int i, j; |
| 13328 | static char code[] = "{\n\ |
| 13329 | unsigned int a = p1;\n\ |
| 13330 | unsigned int b = p2;\n\ |
| 13331 | return a ^ b;\n\ |
| 13332 | }"; |
| 13333 | |
| 13334 | unsigned int (*proc)(unsigned int a, unsigned int b); |
| 13335 | cod_parse_context context = new_cod_parse_context(); |
| 13336 | int dumped = 0; |
| 13337 | |
| 13338 | cod_code gen_code; |
| 13339 | |
| 13340 | /* test for unsigned int ^ unsigned int */ |
| 13341 | if (verbose) printf("test for unsigned int ^ unsigned int"); |
| 13342 | |
| 13343 | cod_assoc_externs(context, externs); |
| 13344 | cod_parse_for_context(extern_string, context); |
| 13345 | |
| 13346 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, unsigned int p2)", |
| 13347 | context); |
| 13348 | gen_code = cod_code_gen(code, context); |
| 13349 | proc = (unsigned int (*)(unsigned int, unsigned int))(long)gen_code->func; |
| 13350 | |
| 13351 | |
| 13352 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 13353 | unsigned int source1_u = src1u_vals[i]; |
| 13354 | for (j=0 ; j < sizeof(src2u_vals)/sizeof(src2u_vals[0]) ; j++) { |
| 13355 | unsigned int source2_u = src2u_vals[j]; |
| 13356 | |
| 13357 | unsigned int expected_result; |
| 13358 | unsigned int result; |
| 13359 | |
| 13360 | |
| 13361 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 13362 | |
| 13363 | expected_result = (unsigned int) (source1_u ^ source2_u); |
| 13364 | |
| 13365 | result = proc(source1_u, source2_u); |
| 13366 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 13367 | if (expected_result != result) { |
| 13368 | printf("Failed unsigned int ^ unsigned int test, expected %u, got %u, for %u ^ %u\n", |
| 13369 | expected_result, result, source1_u, source2_u); |
| 13370 | if (dumped == 0) cod_dump(gen_code); |
| 13371 | failed++; |
| 13372 | dumped++; |
| 13373 | } |
| 13374 | } |
| 13375 | } |
| 13376 | if (verbose) printf(" done\n"); |
| 13377 | cod_free_parse_context(context); |
| 13378 | cod_code_free(gen_code); |
| 13379 | } |
| 13380 | if ((only_run_test == NULL((void*)0)) || |
| 13381 | (strcmp(only_run_test, "u^ul") == 0)) { |
| 13382 | int i, j; |
| 13383 | static char code[] = "{\n\ |
| 13384 | unsigned int a = p1;\n\ |
| 13385 | unsigned long b = p2;\n\ |
| 13386 | return a ^ b;\n\ |
| 13387 | }"; |
| 13388 | |
| 13389 | unsigned int (*proc)(unsigned int a, unsigned long b); |
| 13390 | cod_parse_context context = new_cod_parse_context(); |
| 13391 | int dumped = 0; |
| 13392 | |
| 13393 | cod_code gen_code; |
| 13394 | |
| 13395 | /* test for unsigned int ^ unsigned long */ |
| 13396 | if (verbose) printf("test for unsigned int ^ unsigned long"); |
| 13397 | |
| 13398 | cod_assoc_externs(context, externs); |
| 13399 | cod_parse_for_context(extern_string, context); |
| 13400 | |
| 13401 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, unsigned long p2)", |
| 13402 | context); |
| 13403 | gen_code = cod_code_gen(code, context); |
| 13404 | proc = (unsigned int (*)(unsigned int, unsigned long))(long)gen_code->func; |
| 13405 | |
| 13406 | |
| 13407 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 13408 | unsigned int source1_u = src1u_vals[i]; |
| 13409 | for (j=0 ; j < sizeof(src2ul_vals)/sizeof(src2ul_vals[0]) ; j++) { |
| 13410 | unsigned long source2_ul = src2ul_vals[j]; |
| 13411 | |
| 13412 | unsigned int expected_result; |
| 13413 | unsigned int result; |
| 13414 | |
| 13415 | |
| 13416 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 13417 | |
| 13418 | expected_result = (unsigned int) (source1_u ^ source2_ul); |
| 13419 | |
| 13420 | result = proc(source1_u, source2_ul); |
| 13421 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 13422 | if (expected_result != result) { |
| 13423 | printf("Failed unsigned int ^ unsigned long test, expected %u, got %u, for %u ^ %lu\n", |
| 13424 | expected_result, result, source1_u, source2_ul); |
| 13425 | if (dumped == 0) cod_dump(gen_code); |
| 13426 | failed++; |
| 13427 | dumped++; |
| 13428 | } |
| 13429 | } |
| 13430 | } |
| 13431 | if (verbose) printf(" done\n"); |
| 13432 | cod_free_parse_context(context); |
| 13433 | cod_code_free(gen_code); |
| 13434 | } |
| 13435 | if ((only_run_test == NULL((void*)0)) || |
| 13436 | (strcmp(only_run_test, "u^l") == 0)) { |
| 13437 | int i, j; |
| 13438 | static char code[] = "{\n\ |
| 13439 | unsigned int a = p1;\n\ |
| 13440 | long b = p2;\n\ |
| 13441 | return a ^ b;\n\ |
| 13442 | }"; |
| 13443 | |
| 13444 | unsigned int (*proc)(unsigned int a, long b); |
| 13445 | cod_parse_context context = new_cod_parse_context(); |
| 13446 | int dumped = 0; |
| 13447 | |
| 13448 | cod_code gen_code; |
| 13449 | |
| 13450 | /* test for unsigned int ^ long */ |
| 13451 | if (verbose) printf("test for unsigned int ^ long"); |
| 13452 | |
| 13453 | cod_assoc_externs(context, externs); |
| 13454 | cod_parse_for_context(extern_string, context); |
| 13455 | |
| 13456 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, long p2)", |
| 13457 | context); |
| 13458 | gen_code = cod_code_gen(code, context); |
| 13459 | proc = (unsigned int (*)(unsigned int, long))(long)gen_code->func; |
| 13460 | |
| 13461 | |
| 13462 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 13463 | unsigned int source1_u = src1u_vals[i]; |
| 13464 | for (j=0 ; j < sizeof(src2l_vals)/sizeof(src2l_vals[0]) ; j++) { |
| 13465 | long source2_l = src2l_vals[j]; |
| 13466 | |
| 13467 | unsigned int expected_result; |
| 13468 | unsigned int result; |
| 13469 | |
| 13470 | |
| 13471 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 13472 | |
| 13473 | expected_result = (unsigned int) (source1_u ^ source2_l); |
| 13474 | |
| 13475 | result = proc(source1_u, source2_l); |
| 13476 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 13477 | if (expected_result != result) { |
| 13478 | printf("Failed unsigned int ^ long test, expected %u, got %u, for %u ^ %ld\n", |
| 13479 | expected_result, result, source1_u, source2_l); |
| 13480 | if (dumped == 0) cod_dump(gen_code); |
| 13481 | failed++; |
| 13482 | dumped++; |
| 13483 | } |
| 13484 | } |
| 13485 | } |
| 13486 | if (verbose) printf(" done\n"); |
| 13487 | cod_free_parse_context(context); |
| 13488 | cod_code_free(gen_code); |
| 13489 | } |
| 13490 | } |
| 13491 | void not_ul_tests() |
| 13492 | { |
| 13493 | if ((only_run_test == NULL((void*)0)) || |
| 13494 | (strcmp(only_run_test, "ul^c") == 0)) { |
| 13495 | int i, j; |
| 13496 | static char code[] = "{\n\ |
| 13497 | unsigned long a = p1;\n\ |
| 13498 | signed char b = p2;\n\ |
| 13499 | return a ^ b;\n\ |
| 13500 | }"; |
| 13501 | |
| 13502 | unsigned long (*proc)(unsigned long a, signed char b); |
| 13503 | cod_parse_context context = new_cod_parse_context(); |
| 13504 | int dumped = 0; |
| 13505 | |
| 13506 | cod_code gen_code; |
| 13507 | |
| 13508 | /* test for unsigned long ^ signed char */ |
| 13509 | if (verbose) printf("test for unsigned long ^ signed char"); |
| 13510 | |
| 13511 | cod_assoc_externs(context, externs); |
| 13512 | cod_parse_for_context(extern_string, context); |
| 13513 | |
| 13514 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, signed char p2)", |
| 13515 | context); |
| 13516 | gen_code = cod_code_gen(code, context); |
| 13517 | proc = (unsigned long (*)(unsigned long, signed char))(long)gen_code->func; |
| 13518 | |
| 13519 | |
| 13520 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 13521 | unsigned long source1_ul = src1ul_vals[i]; |
| 13522 | for (j=0 ; j < sizeof(src2c_vals)/sizeof(src2c_vals[0]) ; j++) { |
| 13523 | signed char source2_c = src2c_vals[j]; |
| 13524 | |
| 13525 | unsigned long expected_result; |
| 13526 | unsigned long result; |
| 13527 | |
| 13528 | |
| 13529 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 13530 | |
| 13531 | expected_result = (unsigned long) (source1_ul ^ source2_c); |
| 13532 | |
| 13533 | result = proc(source1_ul, source2_c); |
| 13534 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 13535 | if (expected_result != result) { |
| 13536 | printf("Failed unsigned long ^ signed char test, expected %lu, got %lu, for %lu ^ %d\n", |
| 13537 | expected_result, result, source1_ul, source2_c); |
| 13538 | if (dumped == 0) cod_dump(gen_code); |
| 13539 | failed++; |
| 13540 | dumped++; |
| 13541 | } |
| 13542 | } |
| 13543 | } |
| 13544 | if (verbose) printf(" done\n"); |
| 13545 | cod_free_parse_context(context); |
| 13546 | cod_code_free(gen_code); |
| 13547 | } |
| 13548 | if ((only_run_test == NULL((void*)0)) || |
| 13549 | (strcmp(only_run_test, "ul^uc") == 0)) { |
| 13550 | int i, j; |
| 13551 | static char code[] = "{\n\ |
| 13552 | unsigned long a = p1;\n\ |
| 13553 | unsigned char b = p2;\n\ |
| 13554 | return a ^ b;\n\ |
| 13555 | }"; |
| 13556 | |
| 13557 | unsigned long (*proc)(unsigned long a, unsigned char b); |
| 13558 | cod_parse_context context = new_cod_parse_context(); |
| 13559 | int dumped = 0; |
| 13560 | |
| 13561 | cod_code gen_code; |
| 13562 | |
| 13563 | /* test for unsigned long ^ unsigned char */ |
| 13564 | if (verbose) printf("test for unsigned long ^ unsigned char"); |
| 13565 | |
| 13566 | cod_assoc_externs(context, externs); |
| 13567 | cod_parse_for_context(extern_string, context); |
| 13568 | |
| 13569 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, unsigned char p2)", |
| 13570 | context); |
| 13571 | gen_code = cod_code_gen(code, context); |
| 13572 | proc = (unsigned long (*)(unsigned long, unsigned char))(long)gen_code->func; |
| 13573 | |
| 13574 | |
| 13575 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 13576 | unsigned long source1_ul = src1ul_vals[i]; |
| 13577 | for (j=0 ; j < sizeof(src2uc_vals)/sizeof(src2uc_vals[0]) ; j++) { |
| 13578 | unsigned char source2_uc = src2uc_vals[j]; |
| 13579 | |
| 13580 | unsigned long expected_result; |
| 13581 | unsigned long result; |
| 13582 | |
| 13583 | |
| 13584 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 13585 | |
| 13586 | expected_result = (unsigned long) (source1_ul ^ source2_uc); |
| 13587 | |
| 13588 | result = proc(source1_ul, source2_uc); |
| 13589 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 13590 | if (expected_result != result) { |
| 13591 | printf("Failed unsigned long ^ unsigned char test, expected %lu, got %lu, for %lu ^ %u\n", |
| 13592 | expected_result, result, source1_ul, source2_uc); |
| 13593 | if (dumped == 0) cod_dump(gen_code); |
| 13594 | failed++; |
| 13595 | dumped++; |
| 13596 | } |
| 13597 | } |
| 13598 | } |
| 13599 | if (verbose) printf(" done\n"); |
| 13600 | cod_free_parse_context(context); |
| 13601 | cod_code_free(gen_code); |
| 13602 | } |
| 13603 | if ((only_run_test == NULL((void*)0)) || |
| 13604 | (strcmp(only_run_test, "ul^s") == 0)) { |
| 13605 | int i, j; |
| 13606 | static char code[] = "{\n\ |
| 13607 | unsigned long a = p1;\n\ |
| 13608 | short b = p2;\n\ |
| 13609 | return a ^ b;\n\ |
| 13610 | }"; |
| 13611 | |
| 13612 | unsigned long (*proc)(unsigned long a, short b); |
| 13613 | cod_parse_context context = new_cod_parse_context(); |
| 13614 | int dumped = 0; |
| 13615 | |
| 13616 | cod_code gen_code; |
| 13617 | |
| 13618 | /* test for unsigned long ^ short */ |
| 13619 | if (verbose) printf("test for unsigned long ^ short"); |
| 13620 | |
| 13621 | cod_assoc_externs(context, externs); |
| 13622 | cod_parse_for_context(extern_string, context); |
| 13623 | |
| 13624 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, short p2)", |
| 13625 | context); |
| 13626 | gen_code = cod_code_gen(code, context); |
| 13627 | proc = (unsigned long (*)(unsigned long, short))(long)gen_code->func; |
| 13628 | |
| 13629 | |
| 13630 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 13631 | unsigned long source1_ul = src1ul_vals[i]; |
| 13632 | for (j=0 ; j < sizeof(src2s_vals)/sizeof(src2s_vals[0]) ; j++) { |
| 13633 | short source2_s = src2s_vals[j]; |
| 13634 | |
| 13635 | unsigned long expected_result; |
| 13636 | unsigned long result; |
| 13637 | |
| 13638 | |
| 13639 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 13640 | |
| 13641 | expected_result = (unsigned long) (source1_ul ^ source2_s); |
| 13642 | |
| 13643 | result = proc(source1_ul, source2_s); |
| 13644 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 13645 | if (expected_result != result) { |
| 13646 | printf("Failed unsigned long ^ short test, expected %lu, got %lu, for %lu ^ %d\n", |
| 13647 | expected_result, result, source1_ul, source2_s); |
| 13648 | if (dumped == 0) cod_dump(gen_code); |
| 13649 | failed++; |
| 13650 | dumped++; |
| 13651 | } |
| 13652 | } |
| 13653 | } |
| 13654 | if (verbose) printf(" done\n"); |
| 13655 | cod_free_parse_context(context); |
| 13656 | cod_code_free(gen_code); |
| 13657 | } |
| 13658 | if ((only_run_test == NULL((void*)0)) || |
| 13659 | (strcmp(only_run_test, "ul^us") == 0)) { |
| 13660 | int i, j; |
| 13661 | static char code[] = "{\n\ |
| 13662 | unsigned long a = p1;\n\ |
| 13663 | unsigned short b = p2;\n\ |
| 13664 | return a ^ b;\n\ |
| 13665 | }"; |
| 13666 | |
| 13667 | unsigned long (*proc)(unsigned long a, unsigned short b); |
| 13668 | cod_parse_context context = new_cod_parse_context(); |
| 13669 | int dumped = 0; |
| 13670 | |
| 13671 | cod_code gen_code; |
| 13672 | |
| 13673 | /* test for unsigned long ^ unsigned short */ |
| 13674 | if (verbose) printf("test for unsigned long ^ unsigned short"); |
| 13675 | |
| 13676 | cod_assoc_externs(context, externs); |
| 13677 | cod_parse_for_context(extern_string, context); |
| 13678 | |
| 13679 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, unsigned short p2)", |
| 13680 | context); |
| 13681 | gen_code = cod_code_gen(code, context); |
| 13682 | proc = (unsigned long (*)(unsigned long, unsigned short))(long)gen_code->func; |
| 13683 | |
| 13684 | |
| 13685 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 13686 | unsigned long source1_ul = src1ul_vals[i]; |
| 13687 | for (j=0 ; j < sizeof(src2us_vals)/sizeof(src2us_vals[0]) ; j++) { |
| 13688 | unsigned short source2_us = src2us_vals[j]; |
| 13689 | |
| 13690 | unsigned long expected_result; |
| 13691 | unsigned long result; |
| 13692 | |
| 13693 | |
| 13694 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 13695 | |
| 13696 | expected_result = (unsigned long) (source1_ul ^ source2_us); |
| 13697 | |
| 13698 | result = proc(source1_ul, source2_us); |
| 13699 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 13700 | if (expected_result != result) { |
| 13701 | printf("Failed unsigned long ^ unsigned short test, expected %lu, got %lu, for %lu ^ %u\n", |
| 13702 | expected_result, result, source1_ul, source2_us); |
| 13703 | if (dumped == 0) cod_dump(gen_code); |
| 13704 | failed++; |
| 13705 | dumped++; |
| 13706 | } |
| 13707 | } |
| 13708 | } |
| 13709 | if (verbose) printf(" done\n"); |
| 13710 | cod_free_parse_context(context); |
| 13711 | cod_code_free(gen_code); |
| 13712 | } |
| 13713 | if ((only_run_test == NULL((void*)0)) || |
| 13714 | (strcmp(only_run_test, "ul^i") == 0)) { |
| 13715 | int i, j; |
| 13716 | static char code[] = "{\n\ |
| 13717 | unsigned long a = p1;\n\ |
| 13718 | int b = p2;\n\ |
| 13719 | return a ^ b;\n\ |
| 13720 | }"; |
| 13721 | |
| 13722 | unsigned long (*proc)(unsigned long a, int b); |
| 13723 | cod_parse_context context = new_cod_parse_context(); |
| 13724 | int dumped = 0; |
| 13725 | |
| 13726 | cod_code gen_code; |
| 13727 | |
| 13728 | /* test for unsigned long ^ int */ |
| 13729 | if (verbose) printf("test for unsigned long ^ int"); |
| 13730 | |
| 13731 | cod_assoc_externs(context, externs); |
| 13732 | cod_parse_for_context(extern_string, context); |
| 13733 | |
| 13734 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, int p2)", |
| 13735 | context); |
| 13736 | gen_code = cod_code_gen(code, context); |
| 13737 | proc = (unsigned long (*)(unsigned long, int))(long)gen_code->func; |
| 13738 | |
| 13739 | |
| 13740 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 13741 | unsigned long source1_ul = src1ul_vals[i]; |
| 13742 | for (j=0 ; j < sizeof(src2i_vals)/sizeof(src2i_vals[0]) ; j++) { |
| 13743 | int source2_i = src2i_vals[j]; |
| 13744 | |
| 13745 | unsigned long expected_result; |
| 13746 | unsigned long result; |
| 13747 | |
| 13748 | |
| 13749 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 13750 | |
| 13751 | expected_result = (unsigned long) (source1_ul ^ source2_i); |
| 13752 | |
| 13753 | result = proc(source1_ul, source2_i); |
| 13754 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 13755 | if (expected_result != result) { |
| 13756 | printf("Failed unsigned long ^ int test, expected %lu, got %lu, for %lu ^ %d\n", |
| 13757 | expected_result, result, source1_ul, source2_i); |
| 13758 | if (dumped == 0) cod_dump(gen_code); |
| 13759 | failed++; |
| 13760 | dumped++; |
| 13761 | } |
| 13762 | } |
| 13763 | } |
| 13764 | if (verbose) printf(" done\n"); |
| 13765 | cod_free_parse_context(context); |
| 13766 | cod_code_free(gen_code); |
| 13767 | } |
| 13768 | if ((only_run_test == NULL((void*)0)) || |
| 13769 | (strcmp(only_run_test, "ul^u") == 0)) { |
| 13770 | int i, j; |
| 13771 | static char code[] = "{\n\ |
| 13772 | unsigned long a = p1;\n\ |
| 13773 | unsigned int b = p2;\n\ |
| 13774 | return a ^ b;\n\ |
| 13775 | }"; |
| 13776 | |
| 13777 | unsigned long (*proc)(unsigned long a, unsigned int b); |
| 13778 | cod_parse_context context = new_cod_parse_context(); |
| 13779 | int dumped = 0; |
| 13780 | |
| 13781 | cod_code gen_code; |
| 13782 | |
| 13783 | /* test for unsigned long ^ unsigned int */ |
| 13784 | if (verbose) printf("test for unsigned long ^ unsigned int"); |
| 13785 | |
| 13786 | cod_assoc_externs(context, externs); |
| 13787 | cod_parse_for_context(extern_string, context); |
| 13788 | |
| 13789 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, unsigned int p2)", |
| 13790 | context); |
| 13791 | gen_code = cod_code_gen(code, context); |
| 13792 | proc = (unsigned long (*)(unsigned long, unsigned int))(long)gen_code->func; |
| 13793 | |
| 13794 | |
| 13795 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 13796 | unsigned long source1_ul = src1ul_vals[i]; |
| 13797 | for (j=0 ; j < sizeof(src2u_vals)/sizeof(src2u_vals[0]) ; j++) { |
| 13798 | unsigned int source2_u = src2u_vals[j]; |
| 13799 | |
| 13800 | unsigned long expected_result; |
| 13801 | unsigned long result; |
| 13802 | |
| 13803 | |
| 13804 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 13805 | |
| 13806 | expected_result = (unsigned long) (source1_ul ^ source2_u); |
| 13807 | |
| 13808 | result = proc(source1_ul, source2_u); |
| 13809 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 13810 | if (expected_result != result) { |
| 13811 | printf("Failed unsigned long ^ unsigned int test, expected %lu, got %lu, for %lu ^ %u\n", |
| 13812 | expected_result, result, source1_ul, source2_u); |
| 13813 | if (dumped == 0) cod_dump(gen_code); |
| 13814 | failed++; |
| 13815 | dumped++; |
| 13816 | } |
| 13817 | } |
| 13818 | } |
| 13819 | if (verbose) printf(" done\n"); |
| 13820 | cod_free_parse_context(context); |
| 13821 | cod_code_free(gen_code); |
| 13822 | } |
| 13823 | if ((only_run_test == NULL((void*)0)) || |
| 13824 | (strcmp(only_run_test, "ul^ul") == 0)) { |
| 13825 | int i, j; |
| 13826 | static char code[] = "{\n\ |
| 13827 | unsigned long a = p1;\n\ |
| 13828 | unsigned long b = p2;\n\ |
| 13829 | return a ^ b;\n\ |
| 13830 | }"; |
| 13831 | |
| 13832 | unsigned long (*proc)(unsigned long a, unsigned long b); |
| 13833 | cod_parse_context context = new_cod_parse_context(); |
| 13834 | int dumped = 0; |
| 13835 | |
| 13836 | cod_code gen_code; |
| 13837 | |
| 13838 | /* test for unsigned long ^ unsigned long */ |
| 13839 | if (verbose) printf("test for unsigned long ^ unsigned long"); |
| 13840 | |
| 13841 | cod_assoc_externs(context, externs); |
| 13842 | cod_parse_for_context(extern_string, context); |
| 13843 | |
| 13844 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, unsigned long p2)", |
| 13845 | context); |
| 13846 | gen_code = cod_code_gen(code, context); |
| 13847 | proc = (unsigned long (*)(unsigned long, unsigned long))(long)gen_code->func; |
| 13848 | |
| 13849 | |
| 13850 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 13851 | unsigned long source1_ul = src1ul_vals[i]; |
| 13852 | for (j=0 ; j < sizeof(src2ul_vals)/sizeof(src2ul_vals[0]) ; j++) { |
| 13853 | unsigned long source2_ul = src2ul_vals[j]; |
| 13854 | |
| 13855 | unsigned long expected_result; |
| 13856 | unsigned long result; |
| 13857 | |
| 13858 | |
| 13859 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 13860 | |
| 13861 | expected_result = (unsigned long) (source1_ul ^ source2_ul); |
| 13862 | |
| 13863 | result = proc(source1_ul, source2_ul); |
| 13864 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 13865 | if (expected_result != result) { |
| 13866 | printf("Failed unsigned long ^ unsigned long test, expected %lu, got %lu, for %lu ^ %lu\n", |
| 13867 | expected_result, result, source1_ul, source2_ul); |
| 13868 | if (dumped == 0) cod_dump(gen_code); |
| 13869 | failed++; |
| 13870 | dumped++; |
| 13871 | } |
| 13872 | } |
| 13873 | } |
| 13874 | if (verbose) printf(" done\n"); |
| 13875 | cod_free_parse_context(context); |
| 13876 | cod_code_free(gen_code); |
| 13877 | } |
| 13878 | if ((only_run_test == NULL((void*)0)) || |
| 13879 | (strcmp(only_run_test, "ul^l") == 0)) { |
| 13880 | int i, j; |
| 13881 | static char code[] = "{\n\ |
| 13882 | unsigned long a = p1;\n\ |
| 13883 | long b = p2;\n\ |
| 13884 | return a ^ b;\n\ |
| 13885 | }"; |
| 13886 | |
| 13887 | unsigned long (*proc)(unsigned long a, long b); |
| 13888 | cod_parse_context context = new_cod_parse_context(); |
| 13889 | int dumped = 0; |
| 13890 | |
| 13891 | cod_code gen_code; |
| 13892 | |
| 13893 | /* test for unsigned long ^ long */ |
| 13894 | if (verbose) printf("test for unsigned long ^ long"); |
| 13895 | |
| 13896 | cod_assoc_externs(context, externs); |
| 13897 | cod_parse_for_context(extern_string, context); |
| 13898 | |
| 13899 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, long p2)", |
| 13900 | context); |
| 13901 | gen_code = cod_code_gen(code, context); |
| 13902 | proc = (unsigned long (*)(unsigned long, long))(long)gen_code->func; |
| 13903 | |
| 13904 | |
| 13905 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 13906 | unsigned long source1_ul = src1ul_vals[i]; |
| 13907 | for (j=0 ; j < sizeof(src2l_vals)/sizeof(src2l_vals[0]) ; j++) { |
| 13908 | long source2_l = src2l_vals[j]; |
| 13909 | |
| 13910 | unsigned long expected_result; |
| 13911 | unsigned long result; |
| 13912 | |
| 13913 | |
| 13914 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 13915 | |
| 13916 | expected_result = (unsigned long) (source1_ul ^ source2_l); |
| 13917 | |
| 13918 | result = proc(source1_ul, source2_l); |
| 13919 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 13920 | if (expected_result != result) { |
| 13921 | printf("Failed unsigned long ^ long test, expected %lu, got %lu, for %lu ^ %ld\n", |
| 13922 | expected_result, result, source1_ul, source2_l); |
| 13923 | if (dumped == 0) cod_dump(gen_code); |
| 13924 | failed++; |
| 13925 | dumped++; |
| 13926 | } |
| 13927 | } |
| 13928 | } |
| 13929 | if (verbose) printf(" done\n"); |
| 13930 | cod_free_parse_context(context); |
| 13931 | cod_code_free(gen_code); |
| 13932 | } |
| 13933 | } |
| 13934 | void not_l_tests() |
| 13935 | { |
| 13936 | if ((only_run_test == NULL((void*)0)) || |
| 13937 | (strcmp(only_run_test, "l^c") == 0)) { |
| 13938 | int i, j; |
| 13939 | static char code[] = "{\n\ |
| 13940 | long a = p1;\n\ |
| 13941 | signed char b = p2;\n\ |
| 13942 | return a ^ b;\n\ |
| 13943 | }"; |
| 13944 | |
| 13945 | long (*proc)(long a, signed char b); |
| 13946 | cod_parse_context context = new_cod_parse_context(); |
| 13947 | int dumped = 0; |
| 13948 | |
| 13949 | cod_code gen_code; |
| 13950 | |
| 13951 | /* test for long ^ signed char */ |
| 13952 | if (verbose) printf("test for long ^ signed char"); |
| 13953 | |
| 13954 | cod_assoc_externs(context, externs); |
| 13955 | cod_parse_for_context(extern_string, context); |
| 13956 | |
| 13957 | cod_subroutine_declaration("long proc(long p1, signed char p2)", |
| 13958 | context); |
| 13959 | gen_code = cod_code_gen(code, context); |
| 13960 | proc = (long (*)(long, signed char))(long)gen_code->func; |
| 13961 | |
| 13962 | |
| 13963 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 13964 | long source1_l = src1l_vals[i]; |
| 13965 | for (j=0 ; j < sizeof(src2c_vals)/sizeof(src2c_vals[0]) ; j++) { |
| 13966 | signed char source2_c = src2c_vals[j]; |
| 13967 | |
| 13968 | long expected_result; |
| 13969 | long result; |
| 13970 | |
| 13971 | |
| 13972 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 13973 | |
| 13974 | expected_result = (long) (source1_l ^ source2_c); |
| 13975 | |
| 13976 | result = proc(source1_l, source2_c); |
| 13977 | if (expected_result != result) { |
| 13978 | printf("Failed long ^ signed char test, expected %ld, got %ld, for %ld ^ %d\n", |
| 13979 | expected_result, result, source1_l, source2_c); |
| 13980 | if (dumped == 0) cod_dump(gen_code); |
| 13981 | failed++; |
| 13982 | dumped++; |
| 13983 | } |
| 13984 | } |
| 13985 | } |
| 13986 | if (verbose) printf(" done\n"); |
| 13987 | cod_free_parse_context(context); |
| 13988 | cod_code_free(gen_code); |
| 13989 | } |
| 13990 | if ((only_run_test == NULL((void*)0)) || |
| 13991 | (strcmp(only_run_test, "l^uc") == 0)) { |
| 13992 | int i, j; |
| 13993 | static char code[] = "{\n\ |
| 13994 | long a = p1;\n\ |
| 13995 | unsigned char b = p2;\n\ |
| 13996 | return a ^ b;\n\ |
| 13997 | }"; |
| 13998 | |
| 13999 | long (*proc)(long a, unsigned char b); |
| 14000 | cod_parse_context context = new_cod_parse_context(); |
| 14001 | int dumped = 0; |
| 14002 | |
| 14003 | cod_code gen_code; |
| 14004 | |
| 14005 | /* test for long ^ unsigned char */ |
| 14006 | if (verbose) printf("test for long ^ unsigned char"); |
| 14007 | |
| 14008 | cod_assoc_externs(context, externs); |
| 14009 | cod_parse_for_context(extern_string, context); |
| 14010 | |
| 14011 | cod_subroutine_declaration("long proc(long p1, unsigned char p2)", |
| 14012 | context); |
| 14013 | gen_code = cod_code_gen(code, context); |
| 14014 | proc = (long (*)(long, unsigned char))(long)gen_code->func; |
| 14015 | |
| 14016 | |
| 14017 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 14018 | long source1_l = src1l_vals[i]; |
| 14019 | for (j=0 ; j < sizeof(src2uc_vals)/sizeof(src2uc_vals[0]) ; j++) { |
| 14020 | unsigned char source2_uc = src2uc_vals[j]; |
| 14021 | |
| 14022 | long expected_result; |
| 14023 | long result; |
| 14024 | |
| 14025 | |
| 14026 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 14027 | |
| 14028 | expected_result = (long) (source1_l ^ source2_uc); |
| 14029 | |
| 14030 | result = proc(source1_l, source2_uc); |
| 14031 | if (expected_result != result) { |
| 14032 | printf("Failed long ^ unsigned char test, expected %ld, got %ld, for %ld ^ %u\n", |
| 14033 | expected_result, result, source1_l, source2_uc); |
| 14034 | if (dumped == 0) cod_dump(gen_code); |
| 14035 | failed++; |
| 14036 | dumped++; |
| 14037 | } |
| 14038 | } |
| 14039 | } |
| 14040 | if (verbose) printf(" done\n"); |
| 14041 | cod_free_parse_context(context); |
| 14042 | cod_code_free(gen_code); |
| 14043 | } |
| 14044 | if ((only_run_test == NULL((void*)0)) || |
| 14045 | (strcmp(only_run_test, "l^s") == 0)) { |
| 14046 | int i, j; |
| 14047 | static char code[] = "{\n\ |
| 14048 | long a = p1;\n\ |
| 14049 | short b = p2;\n\ |
| 14050 | return a ^ b;\n\ |
| 14051 | }"; |
| 14052 | |
| 14053 | long (*proc)(long a, short b); |
| 14054 | cod_parse_context context = new_cod_parse_context(); |
| 14055 | int dumped = 0; |
| 14056 | |
| 14057 | cod_code gen_code; |
| 14058 | |
| 14059 | /* test for long ^ short */ |
| 14060 | if (verbose) printf("test for long ^ short"); |
| 14061 | |
| 14062 | cod_assoc_externs(context, externs); |
| 14063 | cod_parse_for_context(extern_string, context); |
| 14064 | |
| 14065 | cod_subroutine_declaration("long proc(long p1, short p2)", |
| 14066 | context); |
| 14067 | gen_code = cod_code_gen(code, context); |
| 14068 | proc = (long (*)(long, short))(long)gen_code->func; |
| 14069 | |
| 14070 | |
| 14071 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 14072 | long source1_l = src1l_vals[i]; |
| 14073 | for (j=0 ; j < sizeof(src2s_vals)/sizeof(src2s_vals[0]) ; j++) { |
| 14074 | short source2_s = src2s_vals[j]; |
| 14075 | |
| 14076 | long expected_result; |
| 14077 | long result; |
| 14078 | |
| 14079 | |
| 14080 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 14081 | |
| 14082 | expected_result = (long) (source1_l ^ source2_s); |
| 14083 | |
| 14084 | result = proc(source1_l, source2_s); |
| 14085 | if (expected_result != result) { |
| 14086 | printf("Failed long ^ short test, expected %ld, got %ld, for %ld ^ %d\n", |
| 14087 | expected_result, result, source1_l, source2_s); |
| 14088 | if (dumped == 0) cod_dump(gen_code); |
| 14089 | failed++; |
| 14090 | dumped++; |
| 14091 | } |
| 14092 | } |
| 14093 | } |
| 14094 | if (verbose) printf(" done\n"); |
| 14095 | cod_free_parse_context(context); |
| 14096 | cod_code_free(gen_code); |
| 14097 | } |
| 14098 | if ((only_run_test == NULL((void*)0)) || |
| 14099 | (strcmp(only_run_test, "l^us") == 0)) { |
| 14100 | int i, j; |
| 14101 | static char code[] = "{\n\ |
| 14102 | long a = p1;\n\ |
| 14103 | unsigned short b = p2;\n\ |
| 14104 | return a ^ b;\n\ |
| 14105 | }"; |
| 14106 | |
| 14107 | long (*proc)(long a, unsigned short b); |
| 14108 | cod_parse_context context = new_cod_parse_context(); |
| 14109 | int dumped = 0; |
| 14110 | |
| 14111 | cod_code gen_code; |
| 14112 | |
| 14113 | /* test for long ^ unsigned short */ |
| 14114 | if (verbose) printf("test for long ^ unsigned short"); |
| 14115 | |
| 14116 | cod_assoc_externs(context, externs); |
| 14117 | cod_parse_for_context(extern_string, context); |
| 14118 | |
| 14119 | cod_subroutine_declaration("long proc(long p1, unsigned short p2)", |
| 14120 | context); |
| 14121 | gen_code = cod_code_gen(code, context); |
| 14122 | proc = (long (*)(long, unsigned short))(long)gen_code->func; |
| 14123 | |
| 14124 | |
| 14125 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 14126 | long source1_l = src1l_vals[i]; |
| 14127 | for (j=0 ; j < sizeof(src2us_vals)/sizeof(src2us_vals[0]) ; j++) { |
| 14128 | unsigned short source2_us = src2us_vals[j]; |
| 14129 | |
| 14130 | long expected_result; |
| 14131 | long result; |
| 14132 | |
| 14133 | |
| 14134 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 14135 | |
| 14136 | expected_result = (long) (source1_l ^ source2_us); |
| 14137 | |
| 14138 | result = proc(source1_l, source2_us); |
| 14139 | if (expected_result != result) { |
| 14140 | printf("Failed long ^ unsigned short test, expected %ld, got %ld, for %ld ^ %u\n", |
| 14141 | expected_result, result, source1_l, source2_us); |
| 14142 | if (dumped == 0) cod_dump(gen_code); |
| 14143 | failed++; |
| 14144 | dumped++; |
| 14145 | } |
| 14146 | } |
| 14147 | } |
| 14148 | if (verbose) printf(" done\n"); |
| 14149 | cod_free_parse_context(context); |
| 14150 | cod_code_free(gen_code); |
| 14151 | } |
| 14152 | if ((only_run_test == NULL((void*)0)) || |
| 14153 | (strcmp(only_run_test, "l^i") == 0)) { |
| 14154 | int i, j; |
| 14155 | static char code[] = "{\n\ |
| 14156 | long a = p1;\n\ |
| 14157 | int b = p2;\n\ |
| 14158 | return a ^ b;\n\ |
| 14159 | }"; |
| 14160 | |
| 14161 | long (*proc)(long a, int b); |
| 14162 | cod_parse_context context = new_cod_parse_context(); |
| 14163 | int dumped = 0; |
| 14164 | |
| 14165 | cod_code gen_code; |
| 14166 | |
| 14167 | /* test for long ^ int */ |
| 14168 | if (verbose) printf("test for long ^ int"); |
| 14169 | |
| 14170 | cod_assoc_externs(context, externs); |
| 14171 | cod_parse_for_context(extern_string, context); |
| 14172 | |
| 14173 | cod_subroutine_declaration("long proc(long p1, int p2)", |
| 14174 | context); |
| 14175 | gen_code = cod_code_gen(code, context); |
| 14176 | proc = (long (*)(long, int))(long)gen_code->func; |
| 14177 | |
| 14178 | |
| 14179 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 14180 | long source1_l = src1l_vals[i]; |
| 14181 | for (j=0 ; j < sizeof(src2i_vals)/sizeof(src2i_vals[0]) ; j++) { |
| 14182 | int source2_i = src2i_vals[j]; |
| 14183 | |
| 14184 | long expected_result; |
| 14185 | long result; |
| 14186 | |
| 14187 | |
| 14188 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 14189 | |
| 14190 | expected_result = (long) (source1_l ^ source2_i); |
| 14191 | |
| 14192 | result = proc(source1_l, source2_i); |
| 14193 | if (expected_result != result) { |
| 14194 | printf("Failed long ^ int test, expected %ld, got %ld, for %ld ^ %d\n", |
| 14195 | expected_result, result, source1_l, source2_i); |
| 14196 | if (dumped == 0) cod_dump(gen_code); |
| 14197 | failed++; |
| 14198 | dumped++; |
| 14199 | } |
| 14200 | } |
| 14201 | } |
| 14202 | if (verbose) printf(" done\n"); |
| 14203 | cod_free_parse_context(context); |
| 14204 | cod_code_free(gen_code); |
| 14205 | } |
| 14206 | if ((only_run_test == NULL((void*)0)) || |
| 14207 | (strcmp(only_run_test, "l^u") == 0)) { |
| 14208 | int i, j; |
| 14209 | static char code[] = "{\n\ |
| 14210 | long a = p1;\n\ |
| 14211 | unsigned int b = p2;\n\ |
| 14212 | return a ^ b;\n\ |
| 14213 | }"; |
| 14214 | |
| 14215 | long (*proc)(long a, unsigned int b); |
| 14216 | cod_parse_context context = new_cod_parse_context(); |
| 14217 | int dumped = 0; |
| 14218 | |
| 14219 | cod_code gen_code; |
| 14220 | |
| 14221 | /* test for long ^ unsigned int */ |
| 14222 | if (verbose) printf("test for long ^ unsigned int"); |
| 14223 | |
| 14224 | cod_assoc_externs(context, externs); |
| 14225 | cod_parse_for_context(extern_string, context); |
| 14226 | |
| 14227 | cod_subroutine_declaration("long proc(long p1, unsigned int p2)", |
| 14228 | context); |
| 14229 | gen_code = cod_code_gen(code, context); |
| 14230 | proc = (long (*)(long, unsigned int))(long)gen_code->func; |
| 14231 | |
| 14232 | |
| 14233 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 14234 | long source1_l = src1l_vals[i]; |
| 14235 | for (j=0 ; j < sizeof(src2u_vals)/sizeof(src2u_vals[0]) ; j++) { |
| 14236 | unsigned int source2_u = src2u_vals[j]; |
| 14237 | |
| 14238 | long expected_result; |
| 14239 | long result; |
| 14240 | |
| 14241 | |
| 14242 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 14243 | |
| 14244 | expected_result = (long) (source1_l ^ source2_u); |
| 14245 | |
| 14246 | result = proc(source1_l, source2_u); |
| 14247 | if (expected_result != result) { |
| 14248 | printf("Failed long ^ unsigned int test, expected %ld, got %ld, for %ld ^ %u\n", |
| 14249 | expected_result, result, source1_l, source2_u); |
| 14250 | if (dumped == 0) cod_dump(gen_code); |
| 14251 | failed++; |
| 14252 | dumped++; |
| 14253 | } |
| 14254 | } |
| 14255 | } |
| 14256 | if (verbose) printf(" done\n"); |
| 14257 | cod_free_parse_context(context); |
| 14258 | cod_code_free(gen_code); |
| 14259 | } |
| 14260 | if ((only_run_test == NULL((void*)0)) || |
| 14261 | (strcmp(only_run_test, "l^ul") == 0)) { |
| 14262 | int i, j; |
| 14263 | static char code[] = "{\n\ |
| 14264 | long a = p1;\n\ |
| 14265 | unsigned long b = p2;\n\ |
| 14266 | return a ^ b;\n\ |
| 14267 | }"; |
| 14268 | |
| 14269 | long (*proc)(long a, unsigned long b); |
| 14270 | cod_parse_context context = new_cod_parse_context(); |
| 14271 | int dumped = 0; |
| 14272 | |
| 14273 | cod_code gen_code; |
| 14274 | |
| 14275 | /* test for long ^ unsigned long */ |
| 14276 | if (verbose) printf("test for long ^ unsigned long"); |
| 14277 | |
| 14278 | cod_assoc_externs(context, externs); |
| 14279 | cod_parse_for_context(extern_string, context); |
| 14280 | |
| 14281 | cod_subroutine_declaration("long proc(long p1, unsigned long p2)", |
| 14282 | context); |
| 14283 | gen_code = cod_code_gen(code, context); |
| 14284 | proc = (long (*)(long, unsigned long))(long)gen_code->func; |
| 14285 | |
| 14286 | |
| 14287 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 14288 | long source1_l = src1l_vals[i]; |
| 14289 | for (j=0 ; j < sizeof(src2ul_vals)/sizeof(src2ul_vals[0]) ; j++) { |
| 14290 | unsigned long source2_ul = src2ul_vals[j]; |
| 14291 | |
| 14292 | long expected_result; |
| 14293 | long result; |
| 14294 | |
| 14295 | |
| 14296 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 14297 | |
| 14298 | expected_result = (long) (source1_l ^ source2_ul); |
| 14299 | |
| 14300 | result = proc(source1_l, source2_ul); |
| 14301 | if (expected_result != result) { |
| 14302 | printf("Failed long ^ unsigned long test, expected %ld, got %ld, for %ld ^ %lu\n", |
| 14303 | expected_result, result, source1_l, source2_ul); |
| 14304 | if (dumped == 0) cod_dump(gen_code); |
| 14305 | failed++; |
| 14306 | dumped++; |
| 14307 | } |
| 14308 | } |
| 14309 | } |
| 14310 | if (verbose) printf(" done\n"); |
| 14311 | cod_free_parse_context(context); |
| 14312 | cod_code_free(gen_code); |
| 14313 | } |
| 14314 | if ((only_run_test == NULL((void*)0)) || |
| 14315 | (strcmp(only_run_test, "l^l") == 0)) { |
| 14316 | int i, j; |
| 14317 | static char code[] = "{\n\ |
| 14318 | long a = p1;\n\ |
| 14319 | long b = p2;\n\ |
| 14320 | return a ^ b;\n\ |
| 14321 | }"; |
| 14322 | |
| 14323 | long (*proc)(long a, long b); |
| 14324 | cod_parse_context context = new_cod_parse_context(); |
| 14325 | int dumped = 0; |
| 14326 | |
| 14327 | cod_code gen_code; |
| 14328 | |
| 14329 | /* test for long ^ long */ |
| 14330 | if (verbose) printf("test for long ^ long"); |
| 14331 | |
| 14332 | cod_assoc_externs(context, externs); |
| 14333 | cod_parse_for_context(extern_string, context); |
| 14334 | |
| 14335 | cod_subroutine_declaration("long proc(long p1, long p2)", |
| 14336 | context); |
| 14337 | gen_code = cod_code_gen(code, context); |
| 14338 | proc = (long (*)(long, long))(long)gen_code->func; |
| 14339 | |
| 14340 | |
| 14341 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 14342 | long source1_l = src1l_vals[i]; |
| 14343 | for (j=0 ; j < sizeof(src2l_vals)/sizeof(src2l_vals[0]) ; j++) { |
| 14344 | long source2_l = src2l_vals[j]; |
| 14345 | |
| 14346 | long expected_result; |
| 14347 | long result; |
| 14348 | |
| 14349 | |
| 14350 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 14351 | |
| 14352 | expected_result = (long) (source1_l ^ source2_l); |
| 14353 | |
| 14354 | result = proc(source1_l, source2_l); |
| 14355 | if (expected_result != result) { |
| 14356 | printf("Failed long ^ long test, expected %ld, got %ld, for %ld ^ %ld\n", |
| 14357 | expected_result, result, source1_l, source2_l); |
| 14358 | if (dumped == 0) cod_dump(gen_code); |
| 14359 | failed++; |
| 14360 | dumped++; |
| 14361 | } |
| 14362 | } |
| 14363 | } |
| 14364 | if (verbose) printf(" done\n"); |
| 14365 | cod_free_parse_context(context); |
| 14366 | cod_code_free(gen_code); |
| 14367 | } |
| 14368 | } |
| 14369 | void lsh_c_tests() |
| 14370 | { |
| 14371 | if ((only_run_test == NULL((void*)0)) || |
| 14372 | (strcmp(only_run_test, "c<<c") == 0)) { |
| 14373 | int i, j; |
| 14374 | static char code[] = "{\n\ |
| 14375 | signed char a = p1;\n\ |
| 14376 | signed char b = p2;\n\ |
| 14377 | return a << b;\n\ |
| 14378 | }"; |
| 14379 | |
| 14380 | signed char (*proc)(signed char a, signed char b); |
| 14381 | cod_parse_context context = new_cod_parse_context(); |
| 14382 | int dumped = 0; |
| 14383 | |
| 14384 | cod_code gen_code; |
| 14385 | |
| 14386 | /* test for signed char << signed char */ |
| 14387 | if (verbose) printf("test for signed char << signed char"); |
| 14388 | |
| 14389 | cod_assoc_externs(context, externs); |
| 14390 | cod_parse_for_context(extern_string, context); |
| 14391 | |
| 14392 | cod_subroutine_declaration("signed char proc(signed char p1, signed char p2)", |
| 14393 | context); |
| 14394 | gen_code = cod_code_gen(code, context); |
| 14395 | proc = (signed char (*)(signed char, signed char))(long)gen_code->func; |
| 14396 | |
| 14397 | |
| 14398 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 14399 | signed char source1_c = src1c_vals[i]; |
| 14400 | for (j=0 ; j < sizeof(sh_src2c_vals)/sizeof(sh_src2c_vals[0]) ; j++) { |
| 14401 | signed char source2_c = sh_src2c_vals[j]; |
| 14402 | |
| 14403 | signed char expected_result; |
| 14404 | signed char result; |
| 14405 | |
| 14406 | |
| 14407 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 14408 | |
| 14409 | expected_result = (signed char) (source1_c << source2_c); |
| 14410 | |
| 14411 | result = proc(source1_c, source2_c); |
| 14412 | if (expected_result != result) { |
| 14413 | printf("Failed signed char << signed char test, expected %d, got %d, for %d << %d\n", |
| 14414 | expected_result, result, source1_c, source2_c); |
| 14415 | if (dumped == 0) cod_dump(gen_code); |
| 14416 | failed++; |
| 14417 | dumped++; |
| 14418 | } |
| 14419 | } |
| 14420 | } |
| 14421 | if (verbose) printf(" done\n"); |
| 14422 | cod_free_parse_context(context); |
| 14423 | cod_code_free(gen_code); |
| 14424 | } |
| 14425 | if ((only_run_test == NULL((void*)0)) || |
| 14426 | (strcmp(only_run_test, "c<<uc") == 0)) { |
| 14427 | int i, j; |
| 14428 | static char code[] = "{\n\ |
| 14429 | signed char a = p1;\n\ |
| 14430 | unsigned char b = p2;\n\ |
| 14431 | return a << b;\n\ |
| 14432 | }"; |
| 14433 | |
| 14434 | signed char (*proc)(signed char a, unsigned char b); |
| 14435 | cod_parse_context context = new_cod_parse_context(); |
| 14436 | int dumped = 0; |
| 14437 | |
| 14438 | cod_code gen_code; |
| 14439 | |
| 14440 | /* test for signed char << unsigned char */ |
| 14441 | if (verbose) printf("test for signed char << unsigned char"); |
| 14442 | |
| 14443 | cod_assoc_externs(context, externs); |
| 14444 | cod_parse_for_context(extern_string, context); |
| 14445 | |
| 14446 | cod_subroutine_declaration("signed char proc(signed char p1, unsigned char p2)", |
| 14447 | context); |
| 14448 | gen_code = cod_code_gen(code, context); |
| 14449 | proc = (signed char (*)(signed char, unsigned char))(long)gen_code->func; |
| 14450 | |
| 14451 | |
| 14452 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 14453 | signed char source1_c = src1c_vals[i]; |
| 14454 | for (j=0 ; j < sizeof(sh_src2c_vals)/sizeof(sh_src2c_vals[0]) ; j++) { |
| 14455 | unsigned char source2_uc = sh_src2c_vals[j]; |
| 14456 | |
| 14457 | signed char expected_result; |
| 14458 | signed char result; |
| 14459 | |
| 14460 | |
| 14461 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 14462 | |
| 14463 | expected_result = (signed char) (source1_c << source2_uc); |
| 14464 | |
| 14465 | result = proc(source1_c, source2_uc); |
| 14466 | if (expected_result != result) { |
| 14467 | printf("Failed signed char << unsigned char test, expected %d, got %d, for %d << %u\n", |
| 14468 | expected_result, result, source1_c, source2_uc); |
| 14469 | if (dumped == 0) cod_dump(gen_code); |
| 14470 | failed++; |
| 14471 | dumped++; |
| 14472 | } |
| 14473 | } |
| 14474 | } |
| 14475 | if (verbose) printf(" done\n"); |
| 14476 | cod_free_parse_context(context); |
| 14477 | cod_code_free(gen_code); |
| 14478 | } |
| 14479 | if ((only_run_test == NULL((void*)0)) || |
| 14480 | (strcmp(only_run_test, "c<<s") == 0)) { |
| 14481 | int i, j; |
| 14482 | static char code[] = "{\n\ |
| 14483 | signed char a = p1;\n\ |
| 14484 | short b = p2;\n\ |
| 14485 | return a << b;\n\ |
| 14486 | }"; |
| 14487 | |
| 14488 | signed char (*proc)(signed char a, short b); |
| 14489 | cod_parse_context context = new_cod_parse_context(); |
| 14490 | int dumped = 0; |
| 14491 | |
| 14492 | cod_code gen_code; |
| 14493 | |
| 14494 | /* test for signed char << short */ |
| 14495 | if (verbose) printf("test for signed char << short"); |
| 14496 | |
| 14497 | cod_assoc_externs(context, externs); |
| 14498 | cod_parse_for_context(extern_string, context); |
| 14499 | |
| 14500 | cod_subroutine_declaration("signed char proc(signed char p1, short p2)", |
| 14501 | context); |
| 14502 | gen_code = cod_code_gen(code, context); |
| 14503 | proc = (signed char (*)(signed char, short))(long)gen_code->func; |
| 14504 | |
| 14505 | |
| 14506 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 14507 | signed char source1_c = src1c_vals[i]; |
| 14508 | for (j=0 ; j < sizeof(sh_src2s_vals)/sizeof(sh_src2s_vals[0]) ; j++) { |
| 14509 | short source2_s = sh_src2s_vals[j]; |
| 14510 | |
| 14511 | signed char expected_result; |
| 14512 | signed char result; |
| 14513 | |
| 14514 | |
| 14515 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 14516 | |
| 14517 | expected_result = (signed char) (source1_c << source2_s); |
| 14518 | |
| 14519 | result = proc(source1_c, source2_s); |
| 14520 | if (expected_result != result) { |
| 14521 | printf("Failed signed char << short test, expected %d, got %d, for %d << %d\n", |
| 14522 | expected_result, result, source1_c, source2_s); |
| 14523 | if (dumped == 0) cod_dump(gen_code); |
| 14524 | failed++; |
| 14525 | dumped++; |
| 14526 | } |
| 14527 | } |
| 14528 | } |
| 14529 | if (verbose) printf(" done\n"); |
| 14530 | cod_free_parse_context(context); |
| 14531 | cod_code_free(gen_code); |
| 14532 | } |
| 14533 | if ((only_run_test == NULL((void*)0)) || |
| 14534 | (strcmp(only_run_test, "c<<us") == 0)) { |
| 14535 | int i, j; |
| 14536 | static char code[] = "{\n\ |
| 14537 | signed char a = p1;\n\ |
| 14538 | unsigned short b = p2;\n\ |
| 14539 | return a << b;\n\ |
| 14540 | }"; |
| 14541 | |
| 14542 | signed char (*proc)(signed char a, unsigned short b); |
| 14543 | cod_parse_context context = new_cod_parse_context(); |
| 14544 | int dumped = 0; |
| 14545 | |
| 14546 | cod_code gen_code; |
| 14547 | |
| 14548 | /* test for signed char << unsigned short */ |
| 14549 | if (verbose) printf("test for signed char << unsigned short"); |
| 14550 | |
| 14551 | cod_assoc_externs(context, externs); |
| 14552 | cod_parse_for_context(extern_string, context); |
| 14553 | |
| 14554 | cod_subroutine_declaration("signed char proc(signed char p1, unsigned short p2)", |
| 14555 | context); |
| 14556 | gen_code = cod_code_gen(code, context); |
| 14557 | proc = (signed char (*)(signed char, unsigned short))(long)gen_code->func; |
| 14558 | |
| 14559 | |
| 14560 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 14561 | signed char source1_c = src1c_vals[i]; |
| 14562 | for (j=0 ; j < sizeof(sh_src2s_vals)/sizeof(sh_src2s_vals[0]) ; j++) { |
| 14563 | unsigned short source2_us = sh_src2s_vals[j]; |
| 14564 | |
| 14565 | signed char expected_result; |
| 14566 | signed char result; |
| 14567 | |
| 14568 | |
| 14569 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 14570 | |
| 14571 | expected_result = (signed char) (source1_c << source2_us); |
| 14572 | |
| 14573 | result = proc(source1_c, source2_us); |
| 14574 | if (expected_result != result) { |
| 14575 | printf("Failed signed char << unsigned short test, expected %d, got %d, for %d << %u\n", |
| 14576 | expected_result, result, source1_c, source2_us); |
| 14577 | if (dumped == 0) cod_dump(gen_code); |
| 14578 | failed++; |
| 14579 | dumped++; |
| 14580 | } |
| 14581 | } |
| 14582 | } |
| 14583 | if (verbose) printf(" done\n"); |
| 14584 | cod_free_parse_context(context); |
| 14585 | cod_code_free(gen_code); |
| 14586 | } |
| 14587 | if ((only_run_test == NULL((void*)0)) || |
| 14588 | (strcmp(only_run_test, "c<<i") == 0)) { |
| 14589 | int i, j; |
| 14590 | static char code[] = "{\n\ |
| 14591 | signed char a = p1;\n\ |
| 14592 | int b = p2;\n\ |
| 14593 | return a << b;\n\ |
| 14594 | }"; |
| 14595 | |
| 14596 | signed char (*proc)(signed char a, int b); |
| 14597 | cod_parse_context context = new_cod_parse_context(); |
| 14598 | int dumped = 0; |
| 14599 | |
| 14600 | cod_code gen_code; |
| 14601 | |
| 14602 | /* test for signed char << int */ |
| 14603 | if (verbose) printf("test for signed char << int"); |
| 14604 | |
| 14605 | cod_assoc_externs(context, externs); |
| 14606 | cod_parse_for_context(extern_string, context); |
| 14607 | |
| 14608 | cod_subroutine_declaration("signed char proc(signed char p1, int p2)", |
| 14609 | context); |
| 14610 | gen_code = cod_code_gen(code, context); |
| 14611 | proc = (signed char (*)(signed char, int))(long)gen_code->func; |
| 14612 | |
| 14613 | |
| 14614 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 14615 | signed char source1_c = src1c_vals[i]; |
| 14616 | for (j=0 ; j < sizeof(sh_src2_vals)/sizeof(sh_src2_vals[0]) ; j++) { |
| 14617 | int source2_i = sh_src2_vals[j]; |
| 14618 | |
| 14619 | signed char expected_result; |
| 14620 | signed char result; |
| 14621 | |
| 14622 | |
| 14623 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 14624 | |
| 14625 | expected_result = (signed char) (source1_c << source2_i); |
| 14626 | |
| 14627 | result = proc(source1_c, source2_i); |
| 14628 | if (expected_result != result) { |
| 14629 | printf("Failed signed char << int test, expected %d, got %d, for %d << %d\n", |
| 14630 | expected_result, result, source1_c, source2_i); |
| 14631 | if (dumped == 0) cod_dump(gen_code); |
| 14632 | failed++; |
| 14633 | dumped++; |
| 14634 | } |
| 14635 | } |
| 14636 | } |
| 14637 | if (verbose) printf(" done\n"); |
| 14638 | cod_free_parse_context(context); |
| 14639 | cod_code_free(gen_code); |
| 14640 | } |
| 14641 | if ((only_run_test == NULL((void*)0)) || |
| 14642 | (strcmp(only_run_test, "c<<u") == 0)) { |
| 14643 | int i, j; |
| 14644 | static char code[] = "{\n\ |
| 14645 | signed char a = p1;\n\ |
| 14646 | unsigned int b = p2;\n\ |
| 14647 | return a << b;\n\ |
| 14648 | }"; |
| 14649 | |
| 14650 | signed char (*proc)(signed char a, unsigned int b); |
| 14651 | cod_parse_context context = new_cod_parse_context(); |
| 14652 | int dumped = 0; |
| 14653 | |
| 14654 | cod_code gen_code; |
| 14655 | |
| 14656 | /* test for signed char << unsigned int */ |
| 14657 | if (verbose) printf("test for signed char << unsigned int"); |
| 14658 | |
| 14659 | cod_assoc_externs(context, externs); |
| 14660 | cod_parse_for_context(extern_string, context); |
| 14661 | |
| 14662 | cod_subroutine_declaration("signed char proc(signed char p1, unsigned int p2)", |
| 14663 | context); |
| 14664 | gen_code = cod_code_gen(code, context); |
| 14665 | proc = (signed char (*)(signed char, unsigned int))(long)gen_code->func; |
| 14666 | |
| 14667 | |
| 14668 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 14669 | signed char source1_c = src1c_vals[i]; |
| 14670 | for (j=0 ; j < sizeof(sh_src2_vals)/sizeof(sh_src2_vals[0]) ; j++) { |
| 14671 | unsigned int source2_u = sh_src2_vals[j]; |
| 14672 | |
| 14673 | signed char expected_result; |
| 14674 | signed char result; |
| 14675 | |
| 14676 | |
| 14677 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 14678 | |
| 14679 | expected_result = (signed char) (source1_c << source2_u); |
| 14680 | |
| 14681 | result = proc(source1_c, source2_u); |
| 14682 | if (expected_result != result) { |
| 14683 | printf("Failed signed char << unsigned int test, expected %d, got %d, for %d << %u\n", |
| 14684 | expected_result, result, source1_c, source2_u); |
| 14685 | if (dumped == 0) cod_dump(gen_code); |
| 14686 | failed++; |
| 14687 | dumped++; |
| 14688 | } |
| 14689 | } |
| 14690 | } |
| 14691 | if (verbose) printf(" done\n"); |
| 14692 | cod_free_parse_context(context); |
| 14693 | cod_code_free(gen_code); |
| 14694 | } |
| 14695 | if ((only_run_test == NULL((void*)0)) || |
| 14696 | (strcmp(only_run_test, "c<<ul") == 0)) { |
| 14697 | int i, j; |
| 14698 | static char code[] = "{\n\ |
| 14699 | signed char a = p1;\n\ |
| 14700 | unsigned long b = p2;\n\ |
| 14701 | return a << b;\n\ |
| 14702 | }"; |
| 14703 | |
| 14704 | signed char (*proc)(signed char a, unsigned long b); |
| 14705 | cod_parse_context context = new_cod_parse_context(); |
| 14706 | int dumped = 0; |
| 14707 | |
| 14708 | cod_code gen_code; |
| 14709 | |
| 14710 | /* test for signed char << unsigned long */ |
| 14711 | if (verbose) printf("test for signed char << unsigned long"); |
| 14712 | |
| 14713 | cod_assoc_externs(context, externs); |
| 14714 | cod_parse_for_context(extern_string, context); |
| 14715 | |
| 14716 | cod_subroutine_declaration("signed char proc(signed char p1, unsigned long p2)", |
| 14717 | context); |
| 14718 | gen_code = cod_code_gen(code, context); |
| 14719 | proc = (signed char (*)(signed char, unsigned long))(long)gen_code->func; |
| 14720 | |
| 14721 | |
| 14722 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 14723 | signed char source1_c = src1c_vals[i]; |
| 14724 | for (j=0 ; j < sizeof(sh_src2_vals)/sizeof(sh_src2_vals[0]) ; j++) { |
| 14725 | unsigned long source2_ul = sh_src2_vals[j]; |
| 14726 | |
| 14727 | signed char expected_result; |
| 14728 | signed char result; |
| 14729 | |
| 14730 | |
| 14731 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 14732 | |
| 14733 | expected_result = (signed char) (source1_c << source2_ul); |
| 14734 | |
| 14735 | result = proc(source1_c, source2_ul); |
| 14736 | if (expected_result != result) { |
| 14737 | printf("Failed signed char << unsigned long test, expected %d, got %d, for %d << %lu\n", |
| 14738 | expected_result, result, source1_c, source2_ul); |
| 14739 | if (dumped == 0) cod_dump(gen_code); |
| 14740 | failed++; |
| 14741 | dumped++; |
| 14742 | } |
| 14743 | } |
| 14744 | } |
| 14745 | if (verbose) printf(" done\n"); |
| 14746 | cod_free_parse_context(context); |
| 14747 | cod_code_free(gen_code); |
| 14748 | } |
| 14749 | if ((only_run_test == NULL((void*)0)) || |
| 14750 | (strcmp(only_run_test, "c<<l") == 0)) { |
| 14751 | int i, j; |
| 14752 | static char code[] = "{\n\ |
| 14753 | signed char a = p1;\n\ |
| 14754 | long b = p2;\n\ |
| 14755 | return a << b;\n\ |
| 14756 | }"; |
| 14757 | |
| 14758 | signed char (*proc)(signed char a, long b); |
| 14759 | cod_parse_context context = new_cod_parse_context(); |
| 14760 | int dumped = 0; |
| 14761 | |
| 14762 | cod_code gen_code; |
| 14763 | |
| 14764 | /* test for signed char << long */ |
| 14765 | if (verbose) printf("test for signed char << long"); |
| 14766 | |
| 14767 | cod_assoc_externs(context, externs); |
| 14768 | cod_parse_for_context(extern_string, context); |
| 14769 | |
| 14770 | cod_subroutine_declaration("signed char proc(signed char p1, long p2)", |
| 14771 | context); |
| 14772 | gen_code = cod_code_gen(code, context); |
| 14773 | proc = (signed char (*)(signed char, long))(long)gen_code->func; |
| 14774 | |
| 14775 | |
| 14776 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 14777 | signed char source1_c = src1c_vals[i]; |
| 14778 | for (j=0 ; j < sizeof(sh_src2_vals)/sizeof(sh_src2_vals[0]) ; j++) { |
| 14779 | long source2_l = sh_src2_vals[j]; |
| 14780 | |
| 14781 | signed char expected_result; |
| 14782 | signed char result; |
| 14783 | |
| 14784 | |
| 14785 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 14786 | |
| 14787 | expected_result = (signed char) (source1_c << source2_l); |
| 14788 | |
| 14789 | result = proc(source1_c, source2_l); |
| 14790 | if (expected_result != result) { |
| 14791 | printf("Failed signed char << long test, expected %d, got %d, for %d << %ld\n", |
| 14792 | expected_result, result, source1_c, source2_l); |
| 14793 | if (dumped == 0) cod_dump(gen_code); |
| 14794 | failed++; |
| 14795 | dumped++; |
| 14796 | } |
| 14797 | } |
| 14798 | } |
| 14799 | if (verbose) printf(" done\n"); |
| 14800 | cod_free_parse_context(context); |
| 14801 | cod_code_free(gen_code); |
| 14802 | } |
| 14803 | } |
| 14804 | void lsh_uc_tests() |
| 14805 | { |
| 14806 | if ((only_run_test == NULL((void*)0)) || |
| 14807 | (strcmp(only_run_test, "uc<<c") == 0)) { |
| 14808 | int i, j; |
| 14809 | static char code[] = "{\n\ |
| 14810 | unsigned char a = p1;\n\ |
| 14811 | signed char b = p2;\n\ |
| 14812 | return a << b;\n\ |
| 14813 | }"; |
| 14814 | |
| 14815 | unsigned char (*proc)(unsigned char a, signed char b); |
| 14816 | cod_parse_context context = new_cod_parse_context(); |
| 14817 | int dumped = 0; |
| 14818 | |
| 14819 | cod_code gen_code; |
| 14820 | |
| 14821 | /* test for unsigned char << signed char */ |
| 14822 | if (verbose) printf("test for unsigned char << signed char"); |
| 14823 | |
| 14824 | cod_assoc_externs(context, externs); |
| 14825 | cod_parse_for_context(extern_string, context); |
| 14826 | |
| 14827 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, signed char p2)", |
| 14828 | context); |
| 14829 | gen_code = cod_code_gen(code, context); |
| 14830 | proc = (unsigned char (*)(unsigned char, signed char))(long)gen_code->func; |
| 14831 | |
| 14832 | |
| 14833 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 14834 | unsigned char source1_uc = src1uc_vals[i]; |
| 14835 | for (j=0 ; j < sizeof(sh_src2c_vals)/sizeof(sh_src2c_vals[0]) ; j++) { |
| 14836 | signed char source2_c = sh_src2c_vals[j]; |
| 14837 | |
| 14838 | unsigned char expected_result; |
| 14839 | unsigned char result; |
| 14840 | |
| 14841 | |
| 14842 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 14843 | |
| 14844 | expected_result = (unsigned char) (source1_uc << source2_c); |
| 14845 | |
| 14846 | result = proc(source1_uc, source2_c); |
| 14847 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 14848 | if (expected_result != result) { |
| 14849 | printf("Failed unsigned char << signed char test, expected %u, got %u, for %u << %d\n", |
| 14850 | expected_result, result, source1_uc, source2_c); |
| 14851 | if (dumped == 0) cod_dump(gen_code); |
| 14852 | failed++; |
| 14853 | dumped++; |
| 14854 | } |
| 14855 | } |
| 14856 | } |
| 14857 | if (verbose) printf(" done\n"); |
| 14858 | cod_free_parse_context(context); |
| 14859 | cod_code_free(gen_code); |
| 14860 | } |
| 14861 | if ((only_run_test == NULL((void*)0)) || |
| 14862 | (strcmp(only_run_test, "uc<<uc") == 0)) { |
| 14863 | int i, j; |
| 14864 | static char code[] = "{\n\ |
| 14865 | unsigned char a = p1;\n\ |
| 14866 | unsigned char b = p2;\n\ |
| 14867 | return a << b;\n\ |
| 14868 | }"; |
| 14869 | |
| 14870 | unsigned char (*proc)(unsigned char a, unsigned char b); |
| 14871 | cod_parse_context context = new_cod_parse_context(); |
| 14872 | int dumped = 0; |
| 14873 | |
| 14874 | cod_code gen_code; |
| 14875 | |
| 14876 | /* test for unsigned char << unsigned char */ |
| 14877 | if (verbose) printf("test for unsigned char << unsigned char"); |
| 14878 | |
| 14879 | cod_assoc_externs(context, externs); |
| 14880 | cod_parse_for_context(extern_string, context); |
| 14881 | |
| 14882 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, unsigned char p2)", |
| 14883 | context); |
| 14884 | gen_code = cod_code_gen(code, context); |
| 14885 | proc = (unsigned char (*)(unsigned char, unsigned char))(long)gen_code->func; |
| 14886 | |
| 14887 | |
| 14888 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 14889 | unsigned char source1_uc = src1uc_vals[i]; |
| 14890 | for (j=0 ; j < sizeof(sh_src2c_vals)/sizeof(sh_src2c_vals[0]) ; j++) { |
| 14891 | unsigned char source2_uc = sh_src2c_vals[j]; |
| 14892 | |
| 14893 | unsigned char expected_result; |
| 14894 | unsigned char result; |
| 14895 | |
| 14896 | |
| 14897 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 14898 | |
| 14899 | expected_result = (unsigned char) (source1_uc << source2_uc); |
| 14900 | |
| 14901 | result = proc(source1_uc, source2_uc); |
| 14902 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 14903 | if (expected_result != result) { |
| 14904 | printf("Failed unsigned char << unsigned char test, expected %u, got %u, for %u << %u\n", |
| 14905 | expected_result, result, source1_uc, source2_uc); |
| 14906 | if (dumped == 0) cod_dump(gen_code); |
| 14907 | failed++; |
| 14908 | dumped++; |
| 14909 | } |
| 14910 | } |
| 14911 | } |
| 14912 | if (verbose) printf(" done\n"); |
| 14913 | cod_free_parse_context(context); |
| 14914 | cod_code_free(gen_code); |
| 14915 | } |
| 14916 | if ((only_run_test == NULL((void*)0)) || |
| 14917 | (strcmp(only_run_test, "uc<<s") == 0)) { |
| 14918 | int i, j; |
| 14919 | static char code[] = "{\n\ |
| 14920 | unsigned char a = p1;\n\ |
| 14921 | short b = p2;\n\ |
| 14922 | return a << b;\n\ |
| 14923 | }"; |
| 14924 | |
| 14925 | unsigned char (*proc)(unsigned char a, short b); |
| 14926 | cod_parse_context context = new_cod_parse_context(); |
| 14927 | int dumped = 0; |
| 14928 | |
| 14929 | cod_code gen_code; |
| 14930 | |
| 14931 | /* test for unsigned char << short */ |
| 14932 | if (verbose) printf("test for unsigned char << short"); |
| 14933 | |
| 14934 | cod_assoc_externs(context, externs); |
| 14935 | cod_parse_for_context(extern_string, context); |
| 14936 | |
| 14937 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, short p2)", |
| 14938 | context); |
| 14939 | gen_code = cod_code_gen(code, context); |
| 14940 | proc = (unsigned char (*)(unsigned char, short))(long)gen_code->func; |
| 14941 | |
| 14942 | |
| 14943 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 14944 | unsigned char source1_uc = src1uc_vals[i]; |
| 14945 | for (j=0 ; j < sizeof(sh_src2s_vals)/sizeof(sh_src2s_vals[0]) ; j++) { |
| 14946 | short source2_s = sh_src2s_vals[j]; |
| 14947 | |
| 14948 | unsigned char expected_result; |
| 14949 | unsigned char result; |
| 14950 | |
| 14951 | |
| 14952 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 14953 | |
| 14954 | expected_result = (unsigned char) (source1_uc << source2_s); |
| 14955 | |
| 14956 | result = proc(source1_uc, source2_s); |
| 14957 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 14958 | if (expected_result != result) { |
| 14959 | printf("Failed unsigned char << short test, expected %u, got %u, for %u << %d\n", |
| 14960 | expected_result, result, source1_uc, source2_s); |
| 14961 | if (dumped == 0) cod_dump(gen_code); |
| 14962 | failed++; |
| 14963 | dumped++; |
| 14964 | } |
| 14965 | } |
| 14966 | } |
| 14967 | if (verbose) printf(" done\n"); |
| 14968 | cod_free_parse_context(context); |
| 14969 | cod_code_free(gen_code); |
| 14970 | } |
| 14971 | if ((only_run_test == NULL((void*)0)) || |
| 14972 | (strcmp(only_run_test, "uc<<us") == 0)) { |
| 14973 | int i, j; |
| 14974 | static char code[] = "{\n\ |
| 14975 | unsigned char a = p1;\n\ |
| 14976 | unsigned short b = p2;\n\ |
| 14977 | return a << b;\n\ |
| 14978 | }"; |
| 14979 | |
| 14980 | unsigned char (*proc)(unsigned char a, unsigned short b); |
| 14981 | cod_parse_context context = new_cod_parse_context(); |
| 14982 | int dumped = 0; |
| 14983 | |
| 14984 | cod_code gen_code; |
| 14985 | |
| 14986 | /* test for unsigned char << unsigned short */ |
| 14987 | if (verbose) printf("test for unsigned char << unsigned short"); |
| 14988 | |
| 14989 | cod_assoc_externs(context, externs); |
| 14990 | cod_parse_for_context(extern_string, context); |
| 14991 | |
| 14992 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, unsigned short p2)", |
| 14993 | context); |
| 14994 | gen_code = cod_code_gen(code, context); |
| 14995 | proc = (unsigned char (*)(unsigned char, unsigned short))(long)gen_code->func; |
| 14996 | |
| 14997 | |
| 14998 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 14999 | unsigned char source1_uc = src1uc_vals[i]; |
| 15000 | for (j=0 ; j < sizeof(sh_src2s_vals)/sizeof(sh_src2s_vals[0]) ; j++) { |
| 15001 | unsigned short source2_us = sh_src2s_vals[j]; |
| 15002 | |
| 15003 | unsigned char expected_result; |
| 15004 | unsigned char result; |
| 15005 | |
| 15006 | |
| 15007 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 15008 | |
| 15009 | expected_result = (unsigned char) (source1_uc << source2_us); |
| 15010 | |
| 15011 | result = proc(source1_uc, source2_us); |
| 15012 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 15013 | if (expected_result != result) { |
| 15014 | printf("Failed unsigned char << unsigned short test, expected %u, got %u, for %u << %u\n", |
| 15015 | expected_result, result, source1_uc, source2_us); |
| 15016 | if (dumped == 0) cod_dump(gen_code); |
| 15017 | failed++; |
| 15018 | dumped++; |
| 15019 | } |
| 15020 | } |
| 15021 | } |
| 15022 | if (verbose) printf(" done\n"); |
| 15023 | cod_free_parse_context(context); |
| 15024 | cod_code_free(gen_code); |
| 15025 | } |
| 15026 | if ((only_run_test == NULL((void*)0)) || |
| 15027 | (strcmp(only_run_test, "uc<<i") == 0)) { |
| 15028 | int i, j; |
| 15029 | static char code[] = "{\n\ |
| 15030 | unsigned char a = p1;\n\ |
| 15031 | int b = p2;\n\ |
| 15032 | return a << b;\n\ |
| 15033 | }"; |
| 15034 | |
| 15035 | unsigned char (*proc)(unsigned char a, int b); |
| 15036 | cod_parse_context context = new_cod_parse_context(); |
| 15037 | int dumped = 0; |
| 15038 | |
| 15039 | cod_code gen_code; |
| 15040 | |
| 15041 | /* test for unsigned char << int */ |
| 15042 | if (verbose) printf("test for unsigned char << int"); |
| 15043 | |
| 15044 | cod_assoc_externs(context, externs); |
| 15045 | cod_parse_for_context(extern_string, context); |
| 15046 | |
| 15047 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, int p2)", |
| 15048 | context); |
| 15049 | gen_code = cod_code_gen(code, context); |
| 15050 | proc = (unsigned char (*)(unsigned char, int))(long)gen_code->func; |
| 15051 | |
| 15052 | |
| 15053 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 15054 | unsigned char source1_uc = src1uc_vals[i]; |
| 15055 | for (j=0 ; j < sizeof(sh_src2_vals)/sizeof(sh_src2_vals[0]) ; j++) { |
| 15056 | int source2_i = sh_src2_vals[j]; |
| 15057 | |
| 15058 | unsigned char expected_result; |
| 15059 | unsigned char result; |
| 15060 | |
| 15061 | |
| 15062 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 15063 | |
| 15064 | expected_result = (unsigned char) (source1_uc << source2_i); |
| 15065 | |
| 15066 | result = proc(source1_uc, source2_i); |
| 15067 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 15068 | if (expected_result != result) { |
| 15069 | printf("Failed unsigned char << int test, expected %u, got %u, for %u << %d\n", |
| 15070 | expected_result, result, source1_uc, source2_i); |
| 15071 | if (dumped == 0) cod_dump(gen_code); |
| 15072 | failed++; |
| 15073 | dumped++; |
| 15074 | } |
| 15075 | } |
| 15076 | } |
| 15077 | if (verbose) printf(" done\n"); |
| 15078 | cod_free_parse_context(context); |
| 15079 | cod_code_free(gen_code); |
| 15080 | } |
| 15081 | if ((only_run_test == NULL((void*)0)) || |
| 15082 | (strcmp(only_run_test, "uc<<u") == 0)) { |
| 15083 | int i, j; |
| 15084 | static char code[] = "{\n\ |
| 15085 | unsigned char a = p1;\n\ |
| 15086 | unsigned int b = p2;\n\ |
| 15087 | return a << b;\n\ |
| 15088 | }"; |
| 15089 | |
| 15090 | unsigned char (*proc)(unsigned char a, unsigned int b); |
| 15091 | cod_parse_context context = new_cod_parse_context(); |
| 15092 | int dumped = 0; |
| 15093 | |
| 15094 | cod_code gen_code; |
| 15095 | |
| 15096 | /* test for unsigned char << unsigned int */ |
| 15097 | if (verbose) printf("test for unsigned char << unsigned int"); |
| 15098 | |
| 15099 | cod_assoc_externs(context, externs); |
| 15100 | cod_parse_for_context(extern_string, context); |
| 15101 | |
| 15102 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, unsigned int p2)", |
| 15103 | context); |
| 15104 | gen_code = cod_code_gen(code, context); |
| 15105 | proc = (unsigned char (*)(unsigned char, unsigned int))(long)gen_code->func; |
| 15106 | |
| 15107 | |
| 15108 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 15109 | unsigned char source1_uc = src1uc_vals[i]; |
| 15110 | for (j=0 ; j < sizeof(sh_src2_vals)/sizeof(sh_src2_vals[0]) ; j++) { |
| 15111 | unsigned int source2_u = sh_src2_vals[j]; |
| 15112 | |
| 15113 | unsigned char expected_result; |
| 15114 | unsigned char result; |
| 15115 | |
| 15116 | |
| 15117 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 15118 | |
| 15119 | expected_result = (unsigned char) (source1_uc << source2_u); |
| 15120 | |
| 15121 | result = proc(source1_uc, source2_u); |
| 15122 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 15123 | if (expected_result != result) { |
| 15124 | printf("Failed unsigned char << unsigned int test, expected %u, got %u, for %u << %u\n", |
| 15125 | expected_result, result, source1_uc, source2_u); |
| 15126 | if (dumped == 0) cod_dump(gen_code); |
| 15127 | failed++; |
| 15128 | dumped++; |
| 15129 | } |
| 15130 | } |
| 15131 | } |
| 15132 | if (verbose) printf(" done\n"); |
| 15133 | cod_free_parse_context(context); |
| 15134 | cod_code_free(gen_code); |
| 15135 | } |
| 15136 | if ((only_run_test == NULL((void*)0)) || |
| 15137 | (strcmp(only_run_test, "uc<<ul") == 0)) { |
| 15138 | int i, j; |
| 15139 | static char code[] = "{\n\ |
| 15140 | unsigned char a = p1;\n\ |
| 15141 | unsigned long b = p2;\n\ |
| 15142 | return a << b;\n\ |
| 15143 | }"; |
| 15144 | |
| 15145 | unsigned char (*proc)(unsigned char a, unsigned long b); |
| 15146 | cod_parse_context context = new_cod_parse_context(); |
| 15147 | int dumped = 0; |
| 15148 | |
| 15149 | cod_code gen_code; |
| 15150 | |
| 15151 | /* test for unsigned char << unsigned long */ |
| 15152 | if (verbose) printf("test for unsigned char << unsigned long"); |
| 15153 | |
| 15154 | cod_assoc_externs(context, externs); |
| 15155 | cod_parse_for_context(extern_string, context); |
| 15156 | |
| 15157 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, unsigned long p2)", |
| 15158 | context); |
| 15159 | gen_code = cod_code_gen(code, context); |
| 15160 | proc = (unsigned char (*)(unsigned char, unsigned long))(long)gen_code->func; |
| 15161 | |
| 15162 | |
| 15163 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 15164 | unsigned char source1_uc = src1uc_vals[i]; |
| 15165 | for (j=0 ; j < sizeof(sh_src2_vals)/sizeof(sh_src2_vals[0]) ; j++) { |
| 15166 | unsigned long source2_ul = sh_src2_vals[j]; |
| 15167 | |
| 15168 | unsigned char expected_result; |
| 15169 | unsigned char result; |
| 15170 | |
| 15171 | |
| 15172 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 15173 | |
| 15174 | expected_result = (unsigned char) (source1_uc << source2_ul); |
| 15175 | |
| 15176 | result = proc(source1_uc, source2_ul); |
| 15177 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 15178 | if (expected_result != result) { |
| 15179 | printf("Failed unsigned char << unsigned long test, expected %u, got %u, for %u << %lu\n", |
| 15180 | expected_result, result, source1_uc, source2_ul); |
| 15181 | if (dumped == 0) cod_dump(gen_code); |
| 15182 | failed++; |
| 15183 | dumped++; |
| 15184 | } |
| 15185 | } |
| 15186 | } |
| 15187 | if (verbose) printf(" done\n"); |
| 15188 | cod_free_parse_context(context); |
| 15189 | cod_code_free(gen_code); |
| 15190 | } |
| 15191 | if ((only_run_test == NULL((void*)0)) || |
| 15192 | (strcmp(only_run_test, "uc<<l") == 0)) { |
| 15193 | int i, j; |
| 15194 | static char code[] = "{\n\ |
| 15195 | unsigned char a = p1;\n\ |
| 15196 | long b = p2;\n\ |
| 15197 | return a << b;\n\ |
| 15198 | }"; |
| 15199 | |
| 15200 | unsigned char (*proc)(unsigned char a, long b); |
| 15201 | cod_parse_context context = new_cod_parse_context(); |
| 15202 | int dumped = 0; |
| 15203 | |
| 15204 | cod_code gen_code; |
| 15205 | |
| 15206 | /* test for unsigned char << long */ |
| 15207 | if (verbose) printf("test for unsigned char << long"); |
| 15208 | |
| 15209 | cod_assoc_externs(context, externs); |
| 15210 | cod_parse_for_context(extern_string, context); |
| 15211 | |
| 15212 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, long p2)", |
| 15213 | context); |
| 15214 | gen_code = cod_code_gen(code, context); |
| 15215 | proc = (unsigned char (*)(unsigned char, long))(long)gen_code->func; |
| 15216 | |
| 15217 | |
| 15218 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 15219 | unsigned char source1_uc = src1uc_vals[i]; |
| 15220 | for (j=0 ; j < sizeof(sh_src2_vals)/sizeof(sh_src2_vals[0]) ; j++) { |
| 15221 | long source2_l = sh_src2_vals[j]; |
| 15222 | |
| 15223 | unsigned char expected_result; |
| 15224 | unsigned char result; |
| 15225 | |
| 15226 | |
| 15227 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 15228 | |
| 15229 | expected_result = (unsigned char) (source1_uc << source2_l); |
| 15230 | |
| 15231 | result = proc(source1_uc, source2_l); |
| 15232 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 15233 | if (expected_result != result) { |
| 15234 | printf("Failed unsigned char << long test, expected %u, got %u, for %u << %ld\n", |
| 15235 | expected_result, result, source1_uc, source2_l); |
| 15236 | if (dumped == 0) cod_dump(gen_code); |
| 15237 | failed++; |
| 15238 | dumped++; |
| 15239 | } |
| 15240 | } |
| 15241 | } |
| 15242 | if (verbose) printf(" done\n"); |
| 15243 | cod_free_parse_context(context); |
| 15244 | cod_code_free(gen_code); |
| 15245 | } |
| 15246 | } |
| 15247 | void lsh_s_tests() |
| 15248 | { |
| 15249 | if ((only_run_test == NULL((void*)0)) || |
| 15250 | (strcmp(only_run_test, "s<<c") == 0)) { |
| 15251 | int i, j; |
| 15252 | static char code[] = "{\n\ |
| 15253 | short a = p1;\n\ |
| 15254 | signed char b = p2;\n\ |
| 15255 | return a << b;\n\ |
| 15256 | }"; |
| 15257 | |
| 15258 | short (*proc)(short a, signed char b); |
| 15259 | cod_parse_context context = new_cod_parse_context(); |
| 15260 | int dumped = 0; |
| 15261 | |
| 15262 | cod_code gen_code; |
| 15263 | |
| 15264 | /* test for short << signed char */ |
| 15265 | if (verbose) printf("test for short << signed char"); |
| 15266 | |
| 15267 | cod_assoc_externs(context, externs); |
| 15268 | cod_parse_for_context(extern_string, context); |
| 15269 | |
| 15270 | cod_subroutine_declaration("short proc(short p1, signed char p2)", |
| 15271 | context); |
| 15272 | gen_code = cod_code_gen(code, context); |
| 15273 | proc = (short (*)(short, signed char))(long)gen_code->func; |
| 15274 | |
| 15275 | |
| 15276 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 15277 | short source1_s = src1s_vals[i]; |
| 15278 | for (j=0 ; j < sizeof(sh_src2c_vals)/sizeof(sh_src2c_vals[0]) ; j++) { |
| 15279 | signed char source2_c = sh_src2c_vals[j]; |
| 15280 | |
| 15281 | short expected_result; |
| 15282 | short result; |
| 15283 | |
| 15284 | |
| 15285 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 15286 | |
| 15287 | expected_result = (short) (source1_s << source2_c); |
| 15288 | |
| 15289 | result = proc(source1_s, source2_c); |
| 15290 | if (expected_result != result) { |
| 15291 | printf("Failed short << signed char test, expected %d, got %d, for %d << %d\n", |
| 15292 | expected_result, result, source1_s, source2_c); |
| 15293 | if (dumped == 0) cod_dump(gen_code); |
| 15294 | failed++; |
| 15295 | dumped++; |
| 15296 | } |
| 15297 | } |
| 15298 | } |
| 15299 | if (verbose) printf(" done\n"); |
| 15300 | cod_free_parse_context(context); |
| 15301 | cod_code_free(gen_code); |
| 15302 | } |
| 15303 | if ((only_run_test == NULL((void*)0)) || |
| 15304 | (strcmp(only_run_test, "s<<uc") == 0)) { |
| 15305 | int i, j; |
| 15306 | static char code[] = "{\n\ |
| 15307 | short a = p1;\n\ |
| 15308 | unsigned char b = p2;\n\ |
| 15309 | return a << b;\n\ |
| 15310 | }"; |
| 15311 | |
| 15312 | short (*proc)(short a, unsigned char b); |
| 15313 | cod_parse_context context = new_cod_parse_context(); |
| 15314 | int dumped = 0; |
| 15315 | |
| 15316 | cod_code gen_code; |
| 15317 | |
| 15318 | /* test for short << unsigned char */ |
| 15319 | if (verbose) printf("test for short << unsigned char"); |
| 15320 | |
| 15321 | cod_assoc_externs(context, externs); |
| 15322 | cod_parse_for_context(extern_string, context); |
| 15323 | |
| 15324 | cod_subroutine_declaration("short proc(short p1, unsigned char p2)", |
| 15325 | context); |
| 15326 | gen_code = cod_code_gen(code, context); |
| 15327 | proc = (short (*)(short, unsigned char))(long)gen_code->func; |
| 15328 | |
| 15329 | |
| 15330 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 15331 | short source1_s = src1s_vals[i]; |
| 15332 | for (j=0 ; j < sizeof(sh_src2c_vals)/sizeof(sh_src2c_vals[0]) ; j++) { |
| 15333 | unsigned char source2_uc = sh_src2c_vals[j]; |
| 15334 | |
| 15335 | short expected_result; |
| 15336 | short result; |
| 15337 | |
| 15338 | |
| 15339 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 15340 | |
| 15341 | expected_result = (short) (source1_s << source2_uc); |
| 15342 | |
| 15343 | result = proc(source1_s, source2_uc); |
| 15344 | if (expected_result != result) { |
| 15345 | printf("Failed short << unsigned char test, expected %d, got %d, for %d << %u\n", |
| 15346 | expected_result, result, source1_s, source2_uc); |
| 15347 | if (dumped == 0) cod_dump(gen_code); |
| 15348 | failed++; |
| 15349 | dumped++; |
| 15350 | } |
| 15351 | } |
| 15352 | } |
| 15353 | if (verbose) printf(" done\n"); |
| 15354 | cod_free_parse_context(context); |
| 15355 | cod_code_free(gen_code); |
| 15356 | } |
| 15357 | if ((only_run_test == NULL((void*)0)) || |
| 15358 | (strcmp(only_run_test, "s<<s") == 0)) { |
| 15359 | int i, j; |
| 15360 | static char code[] = "{\n\ |
| 15361 | short a = p1;\n\ |
| 15362 | short b = p2;\n\ |
| 15363 | return a << b;\n\ |
| 15364 | }"; |
| 15365 | |
| 15366 | short (*proc)(short a, short b); |
| 15367 | cod_parse_context context = new_cod_parse_context(); |
| 15368 | int dumped = 0; |
| 15369 | |
| 15370 | cod_code gen_code; |
| 15371 | |
| 15372 | /* test for short << short */ |
| 15373 | if (verbose) printf("test for short << short"); |
| 15374 | |
| 15375 | cod_assoc_externs(context, externs); |
| 15376 | cod_parse_for_context(extern_string, context); |
| 15377 | |
| 15378 | cod_subroutine_declaration("short proc(short p1, short p2)", |
| 15379 | context); |
| 15380 | gen_code = cod_code_gen(code, context); |
| 15381 | proc = (short (*)(short, short))(long)gen_code->func; |
| 15382 | |
| 15383 | |
| 15384 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 15385 | short source1_s = src1s_vals[i]; |
| 15386 | for (j=0 ; j < sizeof(sh_src2s_vals)/sizeof(sh_src2s_vals[0]) ; j++) { |
| 15387 | short source2_s = sh_src2s_vals[j]; |
| 15388 | |
| 15389 | short expected_result; |
| 15390 | short result; |
| 15391 | |
| 15392 | |
| 15393 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 15394 | |
| 15395 | expected_result = (short) (source1_s << source2_s); |
| 15396 | |
| 15397 | result = proc(source1_s, source2_s); |
| 15398 | if (expected_result != result) { |
| 15399 | printf("Failed short << short test, expected %d, got %d, for %d << %d\n", |
| 15400 | expected_result, result, source1_s, source2_s); |
| 15401 | if (dumped == 0) cod_dump(gen_code); |
| 15402 | failed++; |
| 15403 | dumped++; |
| 15404 | } |
| 15405 | } |
| 15406 | } |
| 15407 | if (verbose) printf(" done\n"); |
| 15408 | cod_free_parse_context(context); |
| 15409 | cod_code_free(gen_code); |
| 15410 | } |
| 15411 | if ((only_run_test == NULL((void*)0)) || |
| 15412 | (strcmp(only_run_test, "s<<us") == 0)) { |
| 15413 | int i, j; |
| 15414 | static char code[] = "{\n\ |
| 15415 | short a = p1;\n\ |
| 15416 | unsigned short b = p2;\n\ |
| 15417 | return a << b;\n\ |
| 15418 | }"; |
| 15419 | |
| 15420 | short (*proc)(short a, unsigned short b); |
| 15421 | cod_parse_context context = new_cod_parse_context(); |
| 15422 | int dumped = 0; |
| 15423 | |
| 15424 | cod_code gen_code; |
| 15425 | |
| 15426 | /* test for short << unsigned short */ |
| 15427 | if (verbose) printf("test for short << unsigned short"); |
| 15428 | |
| 15429 | cod_assoc_externs(context, externs); |
| 15430 | cod_parse_for_context(extern_string, context); |
| 15431 | |
| 15432 | cod_subroutine_declaration("short proc(short p1, unsigned short p2)", |
| 15433 | context); |
| 15434 | gen_code = cod_code_gen(code, context); |
| 15435 | proc = (short (*)(short, unsigned short))(long)gen_code->func; |
| 15436 | |
| 15437 | |
| 15438 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 15439 | short source1_s = src1s_vals[i]; |
| 15440 | for (j=0 ; j < sizeof(sh_src2s_vals)/sizeof(sh_src2s_vals[0]) ; j++) { |
| 15441 | unsigned short source2_us = sh_src2s_vals[j]; |
| 15442 | |
| 15443 | short expected_result; |
| 15444 | short result; |
| 15445 | |
| 15446 | |
| 15447 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 15448 | |
| 15449 | expected_result = (short) (source1_s << source2_us); |
| 15450 | |
| 15451 | result = proc(source1_s, source2_us); |
| 15452 | if (expected_result != result) { |
| 15453 | printf("Failed short << unsigned short test, expected %d, got %d, for %d << %u\n", |
| 15454 | expected_result, result, source1_s, source2_us); |
| 15455 | if (dumped == 0) cod_dump(gen_code); |
| 15456 | failed++; |
| 15457 | dumped++; |
| 15458 | } |
| 15459 | } |
| 15460 | } |
| 15461 | if (verbose) printf(" done\n"); |
| 15462 | cod_free_parse_context(context); |
| 15463 | cod_code_free(gen_code); |
| 15464 | } |
| 15465 | if ((only_run_test == NULL((void*)0)) || |
| 15466 | (strcmp(only_run_test, "s<<i") == 0)) { |
| 15467 | int i, j; |
| 15468 | static char code[] = "{\n\ |
| 15469 | short a = p1;\n\ |
| 15470 | int b = p2;\n\ |
| 15471 | return a << b;\n\ |
| 15472 | }"; |
| 15473 | |
| 15474 | short (*proc)(short a, int b); |
| 15475 | cod_parse_context context = new_cod_parse_context(); |
| 15476 | int dumped = 0; |
| 15477 | |
| 15478 | cod_code gen_code; |
| 15479 | |
| 15480 | /* test for short << int */ |
| 15481 | if (verbose) printf("test for short << int"); |
| 15482 | |
| 15483 | cod_assoc_externs(context, externs); |
| 15484 | cod_parse_for_context(extern_string, context); |
| 15485 | |
| 15486 | cod_subroutine_declaration("short proc(short p1, int p2)", |
| 15487 | context); |
| 15488 | gen_code = cod_code_gen(code, context); |
| 15489 | proc = (short (*)(short, int))(long)gen_code->func; |
| 15490 | |
| 15491 | |
| 15492 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 15493 | short source1_s = src1s_vals[i]; |
| 15494 | for (j=0 ; j < sizeof(sh_src2_vals)/sizeof(sh_src2_vals[0]) ; j++) { |
| 15495 | int source2_i = sh_src2_vals[j]; |
| 15496 | |
| 15497 | short expected_result; |
| 15498 | short result; |
| 15499 | |
| 15500 | |
| 15501 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 15502 | |
| 15503 | expected_result = (short) (source1_s << source2_i); |
| 15504 | |
| 15505 | result = proc(source1_s, source2_i); |
| 15506 | if (expected_result != result) { |
| 15507 | printf("Failed short << int test, expected %d, got %d, for %d << %d\n", |
| 15508 | expected_result, result, source1_s, source2_i); |
| 15509 | if (dumped == 0) cod_dump(gen_code); |
| 15510 | failed++; |
| 15511 | dumped++; |
| 15512 | } |
| 15513 | } |
| 15514 | } |
| 15515 | if (verbose) printf(" done\n"); |
| 15516 | cod_free_parse_context(context); |
| 15517 | cod_code_free(gen_code); |
| 15518 | } |
| 15519 | if ((only_run_test == NULL((void*)0)) || |
| 15520 | (strcmp(only_run_test, "s<<u") == 0)) { |
| 15521 | int i, j; |
| 15522 | static char code[] = "{\n\ |
| 15523 | short a = p1;\n\ |
| 15524 | unsigned int b = p2;\n\ |
| 15525 | return a << b;\n\ |
| 15526 | }"; |
| 15527 | |
| 15528 | short (*proc)(short a, unsigned int b); |
| 15529 | cod_parse_context context = new_cod_parse_context(); |
| 15530 | int dumped = 0; |
| 15531 | |
| 15532 | cod_code gen_code; |
| 15533 | |
| 15534 | /* test for short << unsigned int */ |
| 15535 | if (verbose) printf("test for short << unsigned int"); |
| 15536 | |
| 15537 | cod_assoc_externs(context, externs); |
| 15538 | cod_parse_for_context(extern_string, context); |
| 15539 | |
| 15540 | cod_subroutine_declaration("short proc(short p1, unsigned int p2)", |
| 15541 | context); |
| 15542 | gen_code = cod_code_gen(code, context); |
| 15543 | proc = (short (*)(short, unsigned int))(long)gen_code->func; |
| 15544 | |
| 15545 | |
| 15546 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 15547 | short source1_s = src1s_vals[i]; |
| 15548 | for (j=0 ; j < sizeof(sh_src2_vals)/sizeof(sh_src2_vals[0]) ; j++) { |
| 15549 | unsigned int source2_u = sh_src2_vals[j]; |
| 15550 | |
| 15551 | short expected_result; |
| 15552 | short result; |
| 15553 | |
| 15554 | |
| 15555 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 15556 | |
| 15557 | expected_result = (short) (source1_s << source2_u); |
| 15558 | |
| 15559 | result = proc(source1_s, source2_u); |
| 15560 | if (expected_result != result) { |
| 15561 | printf("Failed short << unsigned int test, expected %d, got %d, for %d << %u\n", |
| 15562 | expected_result, result, source1_s, source2_u); |
| 15563 | if (dumped == 0) cod_dump(gen_code); |
| 15564 | failed++; |
| 15565 | dumped++; |
| 15566 | } |
| 15567 | } |
| 15568 | } |
| 15569 | if (verbose) printf(" done\n"); |
| 15570 | cod_free_parse_context(context); |
| 15571 | cod_code_free(gen_code); |
| 15572 | } |
| 15573 | if ((only_run_test == NULL((void*)0)) || |
| 15574 | (strcmp(only_run_test, "s<<ul") == 0)) { |
| 15575 | int i, j; |
| 15576 | static char code[] = "{\n\ |
| 15577 | short a = p1;\n\ |
| 15578 | unsigned long b = p2;\n\ |
| 15579 | return a << b;\n\ |
| 15580 | }"; |
| 15581 | |
| 15582 | short (*proc)(short a, unsigned long b); |
| 15583 | cod_parse_context context = new_cod_parse_context(); |
| 15584 | int dumped = 0; |
| 15585 | |
| 15586 | cod_code gen_code; |
| 15587 | |
| 15588 | /* test for short << unsigned long */ |
| 15589 | if (verbose) printf("test for short << unsigned long"); |
| 15590 | |
| 15591 | cod_assoc_externs(context, externs); |
| 15592 | cod_parse_for_context(extern_string, context); |
| 15593 | |
| 15594 | cod_subroutine_declaration("short proc(short p1, unsigned long p2)", |
| 15595 | context); |
| 15596 | gen_code = cod_code_gen(code, context); |
| 15597 | proc = (short (*)(short, unsigned long))(long)gen_code->func; |
| 15598 | |
| 15599 | |
| 15600 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 15601 | short source1_s = src1s_vals[i]; |
| 15602 | for (j=0 ; j < sizeof(sh_src2_vals)/sizeof(sh_src2_vals[0]) ; j++) { |
| 15603 | unsigned long source2_ul = sh_src2_vals[j]; |
| 15604 | |
| 15605 | short expected_result; |
| 15606 | short result; |
| 15607 | |
| 15608 | |
| 15609 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 15610 | |
| 15611 | expected_result = (short) (source1_s << source2_ul); |
| 15612 | |
| 15613 | result = proc(source1_s, source2_ul); |
| 15614 | if (expected_result != result) { |
| 15615 | printf("Failed short << unsigned long test, expected %d, got %d, for %d << %lu\n", |
| 15616 | expected_result, result, source1_s, source2_ul); |
| 15617 | if (dumped == 0) cod_dump(gen_code); |
| 15618 | failed++; |
| 15619 | dumped++; |
| 15620 | } |
| 15621 | } |
| 15622 | } |
| 15623 | if (verbose) printf(" done\n"); |
| 15624 | cod_free_parse_context(context); |
| 15625 | cod_code_free(gen_code); |
| 15626 | } |
| 15627 | if ((only_run_test == NULL((void*)0)) || |
| 15628 | (strcmp(only_run_test, "s<<l") == 0)) { |
| 15629 | int i, j; |
| 15630 | static char code[] = "{\n\ |
| 15631 | short a = p1;\n\ |
| 15632 | long b = p2;\n\ |
| 15633 | return a << b;\n\ |
| 15634 | }"; |
| 15635 | |
| 15636 | short (*proc)(short a, long b); |
| 15637 | cod_parse_context context = new_cod_parse_context(); |
| 15638 | int dumped = 0; |
| 15639 | |
| 15640 | cod_code gen_code; |
| 15641 | |
| 15642 | /* test for short << long */ |
| 15643 | if (verbose) printf("test for short << long"); |
| 15644 | |
| 15645 | cod_assoc_externs(context, externs); |
| 15646 | cod_parse_for_context(extern_string, context); |
| 15647 | |
| 15648 | cod_subroutine_declaration("short proc(short p1, long p2)", |
| 15649 | context); |
| 15650 | gen_code = cod_code_gen(code, context); |
| 15651 | proc = (short (*)(short, long))(long)gen_code->func; |
| 15652 | |
| 15653 | |
| 15654 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 15655 | short source1_s = src1s_vals[i]; |
| 15656 | for (j=0 ; j < sizeof(sh_src2_vals)/sizeof(sh_src2_vals[0]) ; j++) { |
| 15657 | long source2_l = sh_src2_vals[j]; |
| 15658 | |
| 15659 | short expected_result; |
| 15660 | short result; |
| 15661 | |
| 15662 | |
| 15663 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 15664 | |
| 15665 | expected_result = (short) (source1_s << source2_l); |
| 15666 | |
| 15667 | result = proc(source1_s, source2_l); |
| 15668 | if (expected_result != result) { |
| 15669 | printf("Failed short << long test, expected %d, got %d, for %d << %ld\n", |
| 15670 | expected_result, result, source1_s, source2_l); |
| 15671 | if (dumped == 0) cod_dump(gen_code); |
| 15672 | failed++; |
| 15673 | dumped++; |
| 15674 | } |
| 15675 | } |
| 15676 | } |
| 15677 | if (verbose) printf(" done\n"); |
| 15678 | cod_free_parse_context(context); |
| 15679 | cod_code_free(gen_code); |
| 15680 | } |
| 15681 | } |
| 15682 | void lsh_us_tests() |
| 15683 | { |
| 15684 | if ((only_run_test == NULL((void*)0)) || |
| 15685 | (strcmp(only_run_test, "us<<c") == 0)) { |
| 15686 | int i, j; |
| 15687 | static char code[] = "{\n\ |
| 15688 | unsigned short a = p1;\n\ |
| 15689 | signed char b = p2;\n\ |
| 15690 | return a << b;\n\ |
| 15691 | }"; |
| 15692 | |
| 15693 | unsigned short (*proc)(unsigned short a, signed char b); |
| 15694 | cod_parse_context context = new_cod_parse_context(); |
| 15695 | int dumped = 0; |
| 15696 | |
| 15697 | cod_code gen_code; |
| 15698 | |
| 15699 | /* test for unsigned short << signed char */ |
| 15700 | if (verbose) printf("test for unsigned short << signed char"); |
| 15701 | |
| 15702 | cod_assoc_externs(context, externs); |
| 15703 | cod_parse_for_context(extern_string, context); |
| 15704 | |
| 15705 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, signed char p2)", |
| 15706 | context); |
| 15707 | gen_code = cod_code_gen(code, context); |
| 15708 | proc = (unsigned short (*)(unsigned short, signed char))(long)gen_code->func; |
| 15709 | |
| 15710 | |
| 15711 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 15712 | unsigned short source1_us = src1us_vals[i]; |
| 15713 | for (j=0 ; j < sizeof(sh_src2c_vals)/sizeof(sh_src2c_vals[0]) ; j++) { |
| 15714 | signed char source2_c = sh_src2c_vals[j]; |
| 15715 | |
| 15716 | unsigned short expected_result; |
| 15717 | unsigned short result; |
| 15718 | |
| 15719 | |
| 15720 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 15721 | |
| 15722 | expected_result = (unsigned short) (source1_us << source2_c); |
| 15723 | |
| 15724 | result = proc(source1_us, source2_c); |
| 15725 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 15726 | if (expected_result != result) { |
| 15727 | printf("Failed unsigned short << signed char test, expected %u, got %u, for %u << %d\n", |
| 15728 | expected_result, result, source1_us, source2_c); |
| 15729 | if (dumped == 0) cod_dump(gen_code); |
| 15730 | failed++; |
| 15731 | dumped++; |
| 15732 | } |
| 15733 | } |
| 15734 | } |
| 15735 | if (verbose) printf(" done\n"); |
| 15736 | cod_free_parse_context(context); |
| 15737 | cod_code_free(gen_code); |
| 15738 | } |
| 15739 | if ((only_run_test == NULL((void*)0)) || |
| 15740 | (strcmp(only_run_test, "us<<uc") == 0)) { |
| 15741 | int i, j; |
| 15742 | static char code[] = "{\n\ |
| 15743 | unsigned short a = p1;\n\ |
| 15744 | unsigned char b = p2;\n\ |
| 15745 | return a << b;\n\ |
| 15746 | }"; |
| 15747 | |
| 15748 | unsigned short (*proc)(unsigned short a, unsigned char b); |
| 15749 | cod_parse_context context = new_cod_parse_context(); |
| 15750 | int dumped = 0; |
| 15751 | |
| 15752 | cod_code gen_code; |
| 15753 | |
| 15754 | /* test for unsigned short << unsigned char */ |
| 15755 | if (verbose) printf("test for unsigned short << unsigned char"); |
| 15756 | |
| 15757 | cod_assoc_externs(context, externs); |
| 15758 | cod_parse_for_context(extern_string, context); |
| 15759 | |
| 15760 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, unsigned char p2)", |
| 15761 | context); |
| 15762 | gen_code = cod_code_gen(code, context); |
| 15763 | proc = (unsigned short (*)(unsigned short, unsigned char))(long)gen_code->func; |
| 15764 | |
| 15765 | |
| 15766 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 15767 | unsigned short source1_us = src1us_vals[i]; |
| 15768 | for (j=0 ; j < sizeof(sh_src2c_vals)/sizeof(sh_src2c_vals[0]) ; j++) { |
| 15769 | unsigned char source2_uc = sh_src2c_vals[j]; |
| 15770 | |
| 15771 | unsigned short expected_result; |
| 15772 | unsigned short result; |
| 15773 | |
| 15774 | |
| 15775 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 15776 | |
| 15777 | expected_result = (unsigned short) (source1_us << source2_uc); |
| 15778 | |
| 15779 | result = proc(source1_us, source2_uc); |
| 15780 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 15781 | if (expected_result != result) { |
| 15782 | printf("Failed unsigned short << unsigned char test, expected %u, got %u, for %u << %u\n", |
| 15783 | expected_result, result, source1_us, source2_uc); |
| 15784 | if (dumped == 0) cod_dump(gen_code); |
| 15785 | failed++; |
| 15786 | dumped++; |
| 15787 | } |
| 15788 | } |
| 15789 | } |
| 15790 | if (verbose) printf(" done\n"); |
| 15791 | cod_free_parse_context(context); |
| 15792 | cod_code_free(gen_code); |
| 15793 | } |
| 15794 | if ((only_run_test == NULL((void*)0)) || |
| 15795 | (strcmp(only_run_test, "us<<s") == 0)) { |
| 15796 | int i, j; |
| 15797 | static char code[] = "{\n\ |
| 15798 | unsigned short a = p1;\n\ |
| 15799 | short b = p2;\n\ |
| 15800 | return a << b;\n\ |
| 15801 | }"; |
| 15802 | |
| 15803 | unsigned short (*proc)(unsigned short a, short b); |
| 15804 | cod_parse_context context = new_cod_parse_context(); |
| 15805 | int dumped = 0; |
| 15806 | |
| 15807 | cod_code gen_code; |
| 15808 | |
| 15809 | /* test for unsigned short << short */ |
| 15810 | if (verbose) printf("test for unsigned short << short"); |
| 15811 | |
| 15812 | cod_assoc_externs(context, externs); |
| 15813 | cod_parse_for_context(extern_string, context); |
| 15814 | |
| 15815 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, short p2)", |
| 15816 | context); |
| 15817 | gen_code = cod_code_gen(code, context); |
| 15818 | proc = (unsigned short (*)(unsigned short, short))(long)gen_code->func; |
| 15819 | |
| 15820 | |
| 15821 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 15822 | unsigned short source1_us = src1us_vals[i]; |
| 15823 | for (j=0 ; j < sizeof(sh_src2s_vals)/sizeof(sh_src2s_vals[0]) ; j++) { |
| 15824 | short source2_s = sh_src2s_vals[j]; |
| 15825 | |
| 15826 | unsigned short expected_result; |
| 15827 | unsigned short result; |
| 15828 | |
| 15829 | |
| 15830 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 15831 | |
| 15832 | expected_result = (unsigned short) (source1_us << source2_s); |
| 15833 | |
| 15834 | result = proc(source1_us, source2_s); |
| 15835 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 15836 | if (expected_result != result) { |
| 15837 | printf("Failed unsigned short << short test, expected %u, got %u, for %u << %d\n", |
| 15838 | expected_result, result, source1_us, source2_s); |
| 15839 | if (dumped == 0) cod_dump(gen_code); |
| 15840 | failed++; |
| 15841 | dumped++; |
| 15842 | } |
| 15843 | } |
| 15844 | } |
| 15845 | if (verbose) printf(" done\n"); |
| 15846 | cod_free_parse_context(context); |
| 15847 | cod_code_free(gen_code); |
| 15848 | } |
| 15849 | if ((only_run_test == NULL((void*)0)) || |
| 15850 | (strcmp(only_run_test, "us<<us") == 0)) { |
| 15851 | int i, j; |
| 15852 | static char code[] = "{\n\ |
| 15853 | unsigned short a = p1;\n\ |
| 15854 | unsigned short b = p2;\n\ |
| 15855 | return a << b;\n\ |
| 15856 | }"; |
| 15857 | |
| 15858 | unsigned short (*proc)(unsigned short a, unsigned short b); |
| 15859 | cod_parse_context context = new_cod_parse_context(); |
| 15860 | int dumped = 0; |
| 15861 | |
| 15862 | cod_code gen_code; |
| 15863 | |
| 15864 | /* test for unsigned short << unsigned short */ |
| 15865 | if (verbose) printf("test for unsigned short << unsigned short"); |
| 15866 | |
| 15867 | cod_assoc_externs(context, externs); |
| 15868 | cod_parse_for_context(extern_string, context); |
| 15869 | |
| 15870 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, unsigned short p2)", |
| 15871 | context); |
| 15872 | gen_code = cod_code_gen(code, context); |
| 15873 | proc = (unsigned short (*)(unsigned short, unsigned short))(long)gen_code->func; |
| 15874 | |
| 15875 | |
| 15876 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 15877 | unsigned short source1_us = src1us_vals[i]; |
| 15878 | for (j=0 ; j < sizeof(sh_src2s_vals)/sizeof(sh_src2s_vals[0]) ; j++) { |
| 15879 | unsigned short source2_us = sh_src2s_vals[j]; |
| 15880 | |
| 15881 | unsigned short expected_result; |
| 15882 | unsigned short result; |
| 15883 | |
| 15884 | |
| 15885 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 15886 | |
| 15887 | expected_result = (unsigned short) (source1_us << source2_us); |
| 15888 | |
| 15889 | result = proc(source1_us, source2_us); |
| 15890 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 15891 | if (expected_result != result) { |
| 15892 | printf("Failed unsigned short << unsigned short test, expected %u, got %u, for %u << %u\n", |
| 15893 | expected_result, result, source1_us, source2_us); |
| 15894 | if (dumped == 0) cod_dump(gen_code); |
| 15895 | failed++; |
| 15896 | dumped++; |
| 15897 | } |
| 15898 | } |
| 15899 | } |
| 15900 | if (verbose) printf(" done\n"); |
| 15901 | cod_free_parse_context(context); |
| 15902 | cod_code_free(gen_code); |
| 15903 | } |
| 15904 | if ((only_run_test == NULL((void*)0)) || |
| 15905 | (strcmp(only_run_test, "us<<i") == 0)) { |
| 15906 | int i, j; |
| 15907 | static char code[] = "{\n\ |
| 15908 | unsigned short a = p1;\n\ |
| 15909 | int b = p2;\n\ |
| 15910 | return a << b;\n\ |
| 15911 | }"; |
| 15912 | |
| 15913 | unsigned short (*proc)(unsigned short a, int b); |
| 15914 | cod_parse_context context = new_cod_parse_context(); |
| 15915 | int dumped = 0; |
| 15916 | |
| 15917 | cod_code gen_code; |
| 15918 | |
| 15919 | /* test for unsigned short << int */ |
| 15920 | if (verbose) printf("test for unsigned short << int"); |
| 15921 | |
| 15922 | cod_assoc_externs(context, externs); |
| 15923 | cod_parse_for_context(extern_string, context); |
| 15924 | |
| 15925 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, int p2)", |
| 15926 | context); |
| 15927 | gen_code = cod_code_gen(code, context); |
| 15928 | proc = (unsigned short (*)(unsigned short, int))(long)gen_code->func; |
| 15929 | |
| 15930 | |
| 15931 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 15932 | unsigned short source1_us = src1us_vals[i]; |
| 15933 | for (j=0 ; j < sizeof(sh_src2_vals)/sizeof(sh_src2_vals[0]) ; j++) { |
| 15934 | int source2_i = sh_src2_vals[j]; |
| 15935 | |
| 15936 | unsigned short expected_result; |
| 15937 | unsigned short result; |
| 15938 | |
| 15939 | |
| 15940 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 15941 | |
| 15942 | expected_result = (unsigned short) (source1_us << source2_i); |
| 15943 | |
| 15944 | result = proc(source1_us, source2_i); |
| 15945 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 15946 | if (expected_result != result) { |
| 15947 | printf("Failed unsigned short << int test, expected %u, got %u, for %u << %d\n", |
| 15948 | expected_result, result, source1_us, source2_i); |
| 15949 | if (dumped == 0) cod_dump(gen_code); |
| 15950 | failed++; |
| 15951 | dumped++; |
| 15952 | } |
| 15953 | } |
| 15954 | } |
| 15955 | if (verbose) printf(" done\n"); |
| 15956 | cod_free_parse_context(context); |
| 15957 | cod_code_free(gen_code); |
| 15958 | } |
| 15959 | if ((only_run_test == NULL((void*)0)) || |
| 15960 | (strcmp(only_run_test, "us<<u") == 0)) { |
| 15961 | int i, j; |
| 15962 | static char code[] = "{\n\ |
| 15963 | unsigned short a = p1;\n\ |
| 15964 | unsigned int b = p2;\n\ |
| 15965 | return a << b;\n\ |
| 15966 | }"; |
| 15967 | |
| 15968 | unsigned short (*proc)(unsigned short a, unsigned int b); |
| 15969 | cod_parse_context context = new_cod_parse_context(); |
| 15970 | int dumped = 0; |
| 15971 | |
| 15972 | cod_code gen_code; |
| 15973 | |
| 15974 | /* test for unsigned short << unsigned int */ |
| 15975 | if (verbose) printf("test for unsigned short << unsigned int"); |
| 15976 | |
| 15977 | cod_assoc_externs(context, externs); |
| 15978 | cod_parse_for_context(extern_string, context); |
| 15979 | |
| 15980 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, unsigned int p2)", |
| 15981 | context); |
| 15982 | gen_code = cod_code_gen(code, context); |
| 15983 | proc = (unsigned short (*)(unsigned short, unsigned int))(long)gen_code->func; |
| 15984 | |
| 15985 | |
| 15986 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 15987 | unsigned short source1_us = src1us_vals[i]; |
| 15988 | for (j=0 ; j < sizeof(sh_src2_vals)/sizeof(sh_src2_vals[0]) ; j++) { |
| 15989 | unsigned int source2_u = sh_src2_vals[j]; |
| 15990 | |
| 15991 | unsigned short expected_result; |
| 15992 | unsigned short result; |
| 15993 | |
| 15994 | |
| 15995 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 15996 | |
| 15997 | expected_result = (unsigned short) (source1_us << source2_u); |
| 15998 | |
| 15999 | result = proc(source1_us, source2_u); |
| 16000 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 16001 | if (expected_result != result) { |
| 16002 | printf("Failed unsigned short << unsigned int test, expected %u, got %u, for %u << %u\n", |
| 16003 | expected_result, result, source1_us, source2_u); |
| 16004 | if (dumped == 0) cod_dump(gen_code); |
| 16005 | failed++; |
| 16006 | dumped++; |
| 16007 | } |
| 16008 | } |
| 16009 | } |
| 16010 | if (verbose) printf(" done\n"); |
| 16011 | cod_free_parse_context(context); |
| 16012 | cod_code_free(gen_code); |
| 16013 | } |
| 16014 | if ((only_run_test == NULL((void*)0)) || |
| 16015 | (strcmp(only_run_test, "us<<ul") == 0)) { |
| 16016 | int i, j; |
| 16017 | static char code[] = "{\n\ |
| 16018 | unsigned short a = p1;\n\ |
| 16019 | unsigned long b = p2;\n\ |
| 16020 | return a << b;\n\ |
| 16021 | }"; |
| 16022 | |
| 16023 | unsigned short (*proc)(unsigned short a, unsigned long b); |
| 16024 | cod_parse_context context = new_cod_parse_context(); |
| 16025 | int dumped = 0; |
| 16026 | |
| 16027 | cod_code gen_code; |
| 16028 | |
| 16029 | /* test for unsigned short << unsigned long */ |
| 16030 | if (verbose) printf("test for unsigned short << unsigned long"); |
| 16031 | |
| 16032 | cod_assoc_externs(context, externs); |
| 16033 | cod_parse_for_context(extern_string, context); |
| 16034 | |
| 16035 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, unsigned long p2)", |
| 16036 | context); |
| 16037 | gen_code = cod_code_gen(code, context); |
| 16038 | proc = (unsigned short (*)(unsigned short, unsigned long))(long)gen_code->func; |
| 16039 | |
| 16040 | |
| 16041 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 16042 | unsigned short source1_us = src1us_vals[i]; |
| 16043 | for (j=0 ; j < sizeof(sh_src2_vals)/sizeof(sh_src2_vals[0]) ; j++) { |
| 16044 | unsigned long source2_ul = sh_src2_vals[j]; |
| 16045 | |
| 16046 | unsigned short expected_result; |
| 16047 | unsigned short result; |
| 16048 | |
| 16049 | |
| 16050 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 16051 | |
| 16052 | expected_result = (unsigned short) (source1_us << source2_ul); |
| 16053 | |
| 16054 | result = proc(source1_us, source2_ul); |
| 16055 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 16056 | if (expected_result != result) { |
| 16057 | printf("Failed unsigned short << unsigned long test, expected %u, got %u, for %u << %lu\n", |
| 16058 | expected_result, result, source1_us, source2_ul); |
| 16059 | if (dumped == 0) cod_dump(gen_code); |
| 16060 | failed++; |
| 16061 | dumped++; |
| 16062 | } |
| 16063 | } |
| 16064 | } |
| 16065 | if (verbose) printf(" done\n"); |
| 16066 | cod_free_parse_context(context); |
| 16067 | cod_code_free(gen_code); |
| 16068 | } |
| 16069 | if ((only_run_test == NULL((void*)0)) || |
| 16070 | (strcmp(only_run_test, "us<<l") == 0)) { |
| 16071 | int i, j; |
| 16072 | static char code[] = "{\n\ |
| 16073 | unsigned short a = p1;\n\ |
| 16074 | long b = p2;\n\ |
| 16075 | return a << b;\n\ |
| 16076 | }"; |
| 16077 | |
| 16078 | unsigned short (*proc)(unsigned short a, long b); |
| 16079 | cod_parse_context context = new_cod_parse_context(); |
| 16080 | int dumped = 0; |
| 16081 | |
| 16082 | cod_code gen_code; |
| 16083 | |
| 16084 | /* test for unsigned short << long */ |
| 16085 | if (verbose) printf("test for unsigned short << long"); |
| 16086 | |
| 16087 | cod_assoc_externs(context, externs); |
| 16088 | cod_parse_for_context(extern_string, context); |
| 16089 | |
| 16090 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, long p2)", |
| 16091 | context); |
| 16092 | gen_code = cod_code_gen(code, context); |
| 16093 | proc = (unsigned short (*)(unsigned short, long))(long)gen_code->func; |
| 16094 | |
| 16095 | |
| 16096 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 16097 | unsigned short source1_us = src1us_vals[i]; |
| 16098 | for (j=0 ; j < sizeof(sh_src2_vals)/sizeof(sh_src2_vals[0]) ; j++) { |
| 16099 | long source2_l = sh_src2_vals[j]; |
| 16100 | |
| 16101 | unsigned short expected_result; |
| 16102 | unsigned short result; |
| 16103 | |
| 16104 | |
| 16105 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 16106 | |
| 16107 | expected_result = (unsigned short) (source1_us << source2_l); |
| 16108 | |
| 16109 | result = proc(source1_us, source2_l); |
| 16110 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 16111 | if (expected_result != result) { |
| 16112 | printf("Failed unsigned short << long test, expected %u, got %u, for %u << %ld\n", |
| 16113 | expected_result, result, source1_us, source2_l); |
| 16114 | if (dumped == 0) cod_dump(gen_code); |
| 16115 | failed++; |
| 16116 | dumped++; |
| 16117 | } |
| 16118 | } |
| 16119 | } |
| 16120 | if (verbose) printf(" done\n"); |
| 16121 | cod_free_parse_context(context); |
| 16122 | cod_code_free(gen_code); |
| 16123 | } |
| 16124 | } |
| 16125 | void lsh_i_tests() |
| 16126 | { |
| 16127 | if ((only_run_test == NULL((void*)0)) || |
| 16128 | (strcmp(only_run_test, "i<<c") == 0)) { |
| 16129 | int i, j; |
| 16130 | static char code[] = "{\n\ |
| 16131 | int a = p1;\n\ |
| 16132 | signed char b = p2;\n\ |
| 16133 | return a << b;\n\ |
| 16134 | }"; |
| 16135 | |
| 16136 | int (*proc)(int a, signed char b); |
| 16137 | cod_parse_context context = new_cod_parse_context(); |
| 16138 | int dumped = 0; |
| 16139 | |
| 16140 | cod_code gen_code; |
| 16141 | |
| 16142 | /* test for int << signed char */ |
| 16143 | if (verbose) printf("test for int << signed char"); |
| 16144 | |
| 16145 | cod_assoc_externs(context, externs); |
| 16146 | cod_parse_for_context(extern_string, context); |
| 16147 | |
| 16148 | cod_subroutine_declaration("int proc(int p1, signed char p2)", |
| 16149 | context); |
| 16150 | gen_code = cod_code_gen(code, context); |
| 16151 | proc = (int (*)(int, signed char))(long)gen_code->func; |
| 16152 | |
| 16153 | |
| 16154 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 16155 | int source1_i = src1i_vals[i]; |
| 16156 | for (j=0 ; j < sizeof(sh_src2c_vals)/sizeof(sh_src2c_vals[0]) ; j++) { |
| 16157 | signed char source2_c = sh_src2c_vals[j]; |
| 16158 | |
| 16159 | int expected_result; |
| 16160 | int result; |
| 16161 | |
| 16162 | |
| 16163 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 16164 | |
| 16165 | expected_result = (int) (source1_i << source2_c); |
| 16166 | |
| 16167 | result = proc(source1_i, source2_c); |
| 16168 | if (expected_result != result) { |
| 16169 | printf("Failed int << signed char test, expected %d, got %d, for %d << %d\n", |
| 16170 | expected_result, result, source1_i, source2_c); |
| 16171 | if (dumped == 0) cod_dump(gen_code); |
| 16172 | failed++; |
| 16173 | dumped++; |
| 16174 | } |
| 16175 | } |
| 16176 | } |
| 16177 | if (verbose) printf(" done\n"); |
| 16178 | cod_free_parse_context(context); |
| 16179 | cod_code_free(gen_code); |
| 16180 | } |
| 16181 | if ((only_run_test == NULL((void*)0)) || |
| 16182 | (strcmp(only_run_test, "i<<uc") == 0)) { |
| 16183 | int i, j; |
| 16184 | static char code[] = "{\n\ |
| 16185 | int a = p1;\n\ |
| 16186 | unsigned char b = p2;\n\ |
| 16187 | return a << b;\n\ |
| 16188 | }"; |
| 16189 | |
| 16190 | int (*proc)(int a, unsigned char b); |
| 16191 | cod_parse_context context = new_cod_parse_context(); |
| 16192 | int dumped = 0; |
| 16193 | |
| 16194 | cod_code gen_code; |
| 16195 | |
| 16196 | /* test for int << unsigned char */ |
| 16197 | if (verbose) printf("test for int << unsigned char"); |
| 16198 | |
| 16199 | cod_assoc_externs(context, externs); |
| 16200 | cod_parse_for_context(extern_string, context); |
| 16201 | |
| 16202 | cod_subroutine_declaration("int proc(int p1, unsigned char p2)", |
| 16203 | context); |
| 16204 | gen_code = cod_code_gen(code, context); |
| 16205 | proc = (int (*)(int, unsigned char))(long)gen_code->func; |
| 16206 | |
| 16207 | |
| 16208 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 16209 | int source1_i = src1i_vals[i]; |
| 16210 | for (j=0 ; j < sizeof(sh_src2c_vals)/sizeof(sh_src2c_vals[0]) ; j++) { |
| 16211 | unsigned char source2_uc = sh_src2c_vals[j]; |
| 16212 | |
| 16213 | int expected_result; |
| 16214 | int result; |
| 16215 | |
| 16216 | |
| 16217 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 16218 | |
| 16219 | expected_result = (int) (source1_i << source2_uc); |
| 16220 | |
| 16221 | result = proc(source1_i, source2_uc); |
| 16222 | if (expected_result != result) { |
| 16223 | printf("Failed int << unsigned char test, expected %d, got %d, for %d << %u\n", |
| 16224 | expected_result, result, source1_i, source2_uc); |
| 16225 | if (dumped == 0) cod_dump(gen_code); |
| 16226 | failed++; |
| 16227 | dumped++; |
| 16228 | } |
| 16229 | } |
| 16230 | } |
| 16231 | if (verbose) printf(" done\n"); |
| 16232 | cod_free_parse_context(context); |
| 16233 | cod_code_free(gen_code); |
| 16234 | } |
| 16235 | if ((only_run_test == NULL((void*)0)) || |
| 16236 | (strcmp(only_run_test, "i<<s") == 0)) { |
| 16237 | int i, j; |
| 16238 | static char code[] = "{\n\ |
| 16239 | int a = p1;\n\ |
| 16240 | short b = p2;\n\ |
| 16241 | return a << b;\n\ |
| 16242 | }"; |
| 16243 | |
| 16244 | int (*proc)(int a, short b); |
| 16245 | cod_parse_context context = new_cod_parse_context(); |
| 16246 | int dumped = 0; |
| 16247 | |
| 16248 | cod_code gen_code; |
| 16249 | |
| 16250 | /* test for int << short */ |
| 16251 | if (verbose) printf("test for int << short"); |
| 16252 | |
| 16253 | cod_assoc_externs(context, externs); |
| 16254 | cod_parse_for_context(extern_string, context); |
| 16255 | |
| 16256 | cod_subroutine_declaration("int proc(int p1, short p2)", |
| 16257 | context); |
| 16258 | gen_code = cod_code_gen(code, context); |
| 16259 | proc = (int (*)(int, short))(long)gen_code->func; |
| 16260 | |
| 16261 | |
| 16262 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 16263 | int source1_i = src1i_vals[i]; |
| 16264 | for (j=0 ; j < sizeof(sh_src2s_vals)/sizeof(sh_src2s_vals[0]) ; j++) { |
| 16265 | short source2_s = sh_src2s_vals[j]; |
| 16266 | |
| 16267 | int expected_result; |
| 16268 | int result; |
| 16269 | |
| 16270 | |
| 16271 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 16272 | |
| 16273 | expected_result = (int) (source1_i << source2_s); |
| 16274 | |
| 16275 | result = proc(source1_i, source2_s); |
| 16276 | if (expected_result != result) { |
| 16277 | printf("Failed int << short test, expected %d, got %d, for %d << %d\n", |
| 16278 | expected_result, result, source1_i, source2_s); |
| 16279 | if (dumped == 0) cod_dump(gen_code); |
| 16280 | failed++; |
| 16281 | dumped++; |
| 16282 | } |
| 16283 | } |
| 16284 | } |
| 16285 | if (verbose) printf(" done\n"); |
| 16286 | cod_free_parse_context(context); |
| 16287 | cod_code_free(gen_code); |
| 16288 | } |
| 16289 | if ((only_run_test == NULL((void*)0)) || |
| 16290 | (strcmp(only_run_test, "i<<us") == 0)) { |
| 16291 | int i, j; |
| 16292 | static char code[] = "{\n\ |
| 16293 | int a = p1;\n\ |
| 16294 | unsigned short b = p2;\n\ |
| 16295 | return a << b;\n\ |
| 16296 | }"; |
| 16297 | |
| 16298 | int (*proc)(int a, unsigned short b); |
| 16299 | cod_parse_context context = new_cod_parse_context(); |
| 16300 | int dumped = 0; |
| 16301 | |
| 16302 | cod_code gen_code; |
| 16303 | |
| 16304 | /* test for int << unsigned short */ |
| 16305 | if (verbose) printf("test for int << unsigned short"); |
| 16306 | |
| 16307 | cod_assoc_externs(context, externs); |
| 16308 | cod_parse_for_context(extern_string, context); |
| 16309 | |
| 16310 | cod_subroutine_declaration("int proc(int p1, unsigned short p2)", |
| 16311 | context); |
| 16312 | gen_code = cod_code_gen(code, context); |
| 16313 | proc = (int (*)(int, unsigned short))(long)gen_code->func; |
| 16314 | |
| 16315 | |
| 16316 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 16317 | int source1_i = src1i_vals[i]; |
| 16318 | for (j=0 ; j < sizeof(sh_src2s_vals)/sizeof(sh_src2s_vals[0]) ; j++) { |
| 16319 | unsigned short source2_us = sh_src2s_vals[j]; |
| 16320 | |
| 16321 | int expected_result; |
| 16322 | int result; |
| 16323 | |
| 16324 | |
| 16325 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 16326 | |
| 16327 | expected_result = (int) (source1_i << source2_us); |
| 16328 | |
| 16329 | result = proc(source1_i, source2_us); |
| 16330 | if (expected_result != result) { |
| 16331 | printf("Failed int << unsigned short test, expected %d, got %d, for %d << %u\n", |
| 16332 | expected_result, result, source1_i, source2_us); |
| 16333 | if (dumped == 0) cod_dump(gen_code); |
| 16334 | failed++; |
| 16335 | dumped++; |
| 16336 | } |
| 16337 | } |
| 16338 | } |
| 16339 | if (verbose) printf(" done\n"); |
| 16340 | cod_free_parse_context(context); |
| 16341 | cod_code_free(gen_code); |
| 16342 | } |
| 16343 | if ((only_run_test == NULL((void*)0)) || |
| 16344 | (strcmp(only_run_test, "i<<i") == 0)) { |
| 16345 | int i, j; |
| 16346 | static char code[] = "{\n\ |
| 16347 | int a = p1;\n\ |
| 16348 | int b = p2;\n\ |
| 16349 | return a << b;\n\ |
| 16350 | }"; |
| 16351 | |
| 16352 | int (*proc)(int a, int b); |
| 16353 | cod_parse_context context = new_cod_parse_context(); |
| 16354 | int dumped = 0; |
| 16355 | |
| 16356 | cod_code gen_code; |
| 16357 | |
| 16358 | /* test for int << int */ |
| 16359 | if (verbose) printf("test for int << int"); |
| 16360 | |
| 16361 | cod_assoc_externs(context, externs); |
| 16362 | cod_parse_for_context(extern_string, context); |
| 16363 | |
| 16364 | cod_subroutine_declaration("int proc(int p1, int p2)", |
| 16365 | context); |
| 16366 | gen_code = cod_code_gen(code, context); |
| 16367 | proc = (int (*)(int, int))(long)gen_code->func; |
| 16368 | |
| 16369 | |
| 16370 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 16371 | int source1_i = src1i_vals[i]; |
| 16372 | for (j=0 ; j < sizeof(sh_src2_vals)/sizeof(sh_src2_vals[0]) ; j++) { |
| 16373 | int source2_i = sh_src2_vals[j]; |
| 16374 | |
| 16375 | int expected_result; |
| 16376 | int result; |
| 16377 | |
| 16378 | |
| 16379 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 16380 | |
| 16381 | expected_result = (int) (source1_i << source2_i); |
| 16382 | |
| 16383 | result = proc(source1_i, source2_i); |
| 16384 | if (expected_result != result) { |
| 16385 | printf("Failed int << int test, expected %d, got %d, for %d << %d\n", |
| 16386 | expected_result, result, source1_i, source2_i); |
| 16387 | if (dumped == 0) cod_dump(gen_code); |
| 16388 | failed++; |
| 16389 | dumped++; |
| 16390 | } |
| 16391 | } |
| 16392 | } |
| 16393 | if (verbose) printf(" done\n"); |
| 16394 | cod_free_parse_context(context); |
| 16395 | cod_code_free(gen_code); |
| 16396 | } |
| 16397 | if ((only_run_test == NULL((void*)0)) || |
| 16398 | (strcmp(only_run_test, "i<<u") == 0)) { |
| 16399 | int i, j; |
| 16400 | static char code[] = "{\n\ |
| 16401 | int a = p1;\n\ |
| 16402 | unsigned int b = p2;\n\ |
| 16403 | return a << b;\n\ |
| 16404 | }"; |
| 16405 | |
| 16406 | int (*proc)(int a, unsigned int b); |
| 16407 | cod_parse_context context = new_cod_parse_context(); |
| 16408 | int dumped = 0; |
| 16409 | |
| 16410 | cod_code gen_code; |
| 16411 | |
| 16412 | /* test for int << unsigned int */ |
| 16413 | if (verbose) printf("test for int << unsigned int"); |
| 16414 | |
| 16415 | cod_assoc_externs(context, externs); |
| 16416 | cod_parse_for_context(extern_string, context); |
| 16417 | |
| 16418 | cod_subroutine_declaration("int proc(int p1, unsigned int p2)", |
| 16419 | context); |
| 16420 | gen_code = cod_code_gen(code, context); |
| 16421 | proc = (int (*)(int, unsigned int))(long)gen_code->func; |
| 16422 | |
| 16423 | |
| 16424 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 16425 | int source1_i = src1i_vals[i]; |
| 16426 | for (j=0 ; j < sizeof(sh_src2_vals)/sizeof(sh_src2_vals[0]) ; j++) { |
| 16427 | unsigned int source2_u = sh_src2_vals[j]; |
| 16428 | |
| 16429 | int expected_result; |
| 16430 | int result; |
| 16431 | |
| 16432 | |
| 16433 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 16434 | |
| 16435 | expected_result = (int) (source1_i << source2_u); |
| 16436 | |
| 16437 | result = proc(source1_i, source2_u); |
| 16438 | if (expected_result != result) { |
| 16439 | printf("Failed int << unsigned int test, expected %d, got %d, for %d << %u\n", |
| 16440 | expected_result, result, source1_i, source2_u); |
| 16441 | if (dumped == 0) cod_dump(gen_code); |
| 16442 | failed++; |
| 16443 | dumped++; |
| 16444 | } |
| 16445 | } |
| 16446 | } |
| 16447 | if (verbose) printf(" done\n"); |
| 16448 | cod_free_parse_context(context); |
| 16449 | cod_code_free(gen_code); |
| 16450 | } |
| 16451 | if ((only_run_test == NULL((void*)0)) || |
| 16452 | (strcmp(only_run_test, "i<<ul") == 0)) { |
| 16453 | int i, j; |
| 16454 | static char code[] = "{\n\ |
| 16455 | int a = p1;\n\ |
| 16456 | unsigned long b = p2;\n\ |
| 16457 | return a << b;\n\ |
| 16458 | }"; |
| 16459 | |
| 16460 | int (*proc)(int a, unsigned long b); |
| 16461 | cod_parse_context context = new_cod_parse_context(); |
| 16462 | int dumped = 0; |
| 16463 | |
| 16464 | cod_code gen_code; |
| 16465 | |
| 16466 | /* test for int << unsigned long */ |
| 16467 | if (verbose) printf("test for int << unsigned long"); |
| 16468 | |
| 16469 | cod_assoc_externs(context, externs); |
| 16470 | cod_parse_for_context(extern_string, context); |
| 16471 | |
| 16472 | cod_subroutine_declaration("int proc(int p1, unsigned long p2)", |
| 16473 | context); |
| 16474 | gen_code = cod_code_gen(code, context); |
| 16475 | proc = (int (*)(int, unsigned long))(long)gen_code->func; |
| 16476 | |
| 16477 | |
| 16478 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 16479 | int source1_i = src1i_vals[i]; |
| 16480 | for (j=0 ; j < sizeof(sh_src2_vals)/sizeof(sh_src2_vals[0]) ; j++) { |
| 16481 | unsigned long source2_ul = sh_src2_vals[j]; |
| 16482 | |
| 16483 | int expected_result; |
| 16484 | int result; |
| 16485 | |
| 16486 | |
| 16487 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 16488 | |
| 16489 | expected_result = (int) (source1_i << source2_ul); |
| 16490 | |
| 16491 | result = proc(source1_i, source2_ul); |
| 16492 | if (expected_result != result) { |
| 16493 | printf("Failed int << unsigned long test, expected %d, got %d, for %d << %lu\n", |
| 16494 | expected_result, result, source1_i, source2_ul); |
| 16495 | if (dumped == 0) cod_dump(gen_code); |
| 16496 | failed++; |
| 16497 | dumped++; |
| 16498 | } |
| 16499 | } |
| 16500 | } |
| 16501 | if (verbose) printf(" done\n"); |
| 16502 | cod_free_parse_context(context); |
| 16503 | cod_code_free(gen_code); |
| 16504 | } |
| 16505 | if ((only_run_test == NULL((void*)0)) || |
| 16506 | (strcmp(only_run_test, "i<<l") == 0)) { |
| 16507 | int i, j; |
| 16508 | static char code[] = "{\n\ |
| 16509 | int a = p1;\n\ |
| 16510 | long b = p2;\n\ |
| 16511 | return a << b;\n\ |
| 16512 | }"; |
| 16513 | |
| 16514 | int (*proc)(int a, long b); |
| 16515 | cod_parse_context context = new_cod_parse_context(); |
| 16516 | int dumped = 0; |
| 16517 | |
| 16518 | cod_code gen_code; |
| 16519 | |
| 16520 | /* test for int << long */ |
| 16521 | if (verbose) printf("test for int << long"); |
| 16522 | |
| 16523 | cod_assoc_externs(context, externs); |
| 16524 | cod_parse_for_context(extern_string, context); |
| 16525 | |
| 16526 | cod_subroutine_declaration("int proc(int p1, long p2)", |
| 16527 | context); |
| 16528 | gen_code = cod_code_gen(code, context); |
| 16529 | proc = (int (*)(int, long))(long)gen_code->func; |
| 16530 | |
| 16531 | |
| 16532 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 16533 | int source1_i = src1i_vals[i]; |
| 16534 | for (j=0 ; j < sizeof(sh_src2_vals)/sizeof(sh_src2_vals[0]) ; j++) { |
| 16535 | long source2_l = sh_src2_vals[j]; |
| 16536 | |
| 16537 | int expected_result; |
| 16538 | int result; |
| 16539 | |
| 16540 | |
| 16541 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 16542 | |
| 16543 | expected_result = (int) (source1_i << source2_l); |
| 16544 | |
| 16545 | result = proc(source1_i, source2_l); |
| 16546 | if (expected_result != result) { |
| 16547 | printf("Failed int << long test, expected %d, got %d, for %d << %ld\n", |
| 16548 | expected_result, result, source1_i, source2_l); |
| 16549 | if (dumped == 0) cod_dump(gen_code); |
| 16550 | failed++; |
| 16551 | dumped++; |
| 16552 | } |
| 16553 | } |
| 16554 | } |
| 16555 | if (verbose) printf(" done\n"); |
| 16556 | cod_free_parse_context(context); |
| 16557 | cod_code_free(gen_code); |
| 16558 | } |
| 16559 | } |
| 16560 | void lsh_u_tests() |
| 16561 | { |
| 16562 | if ((only_run_test == NULL((void*)0)) || |
| 16563 | (strcmp(only_run_test, "u<<c") == 0)) { |
| 16564 | int i, j; |
| 16565 | static char code[] = "{\n\ |
| 16566 | unsigned int a = p1;\n\ |
| 16567 | signed char b = p2;\n\ |
| 16568 | return a << b;\n\ |
| 16569 | }"; |
| 16570 | |
| 16571 | unsigned int (*proc)(unsigned int a, signed char b); |
| 16572 | cod_parse_context context = new_cod_parse_context(); |
| 16573 | int dumped = 0; |
| 16574 | |
| 16575 | cod_code gen_code; |
| 16576 | |
| 16577 | /* test for unsigned int << signed char */ |
| 16578 | if (verbose) printf("test for unsigned int << signed char"); |
| 16579 | |
| 16580 | cod_assoc_externs(context, externs); |
| 16581 | cod_parse_for_context(extern_string, context); |
| 16582 | |
| 16583 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, signed char p2)", |
| 16584 | context); |
| 16585 | gen_code = cod_code_gen(code, context); |
| 16586 | proc = (unsigned int (*)(unsigned int, signed char))(long)gen_code->func; |
| 16587 | |
| 16588 | |
| 16589 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 16590 | unsigned int source1_u = src1u_vals[i]; |
| 16591 | for (j=0 ; j < sizeof(sh_src2c_vals)/sizeof(sh_src2c_vals[0]) ; j++) { |
| 16592 | signed char source2_c = sh_src2c_vals[j]; |
| 16593 | |
| 16594 | unsigned int expected_result; |
| 16595 | unsigned int result; |
| 16596 | |
| 16597 | |
| 16598 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 16599 | |
| 16600 | expected_result = (unsigned int) (source1_u << source2_c); |
| 16601 | |
| 16602 | result = proc(source1_u, source2_c); |
| 16603 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 16604 | if (expected_result != result) { |
| 16605 | printf("Failed unsigned int << signed char test, expected %u, got %u, for %u << %d\n", |
| 16606 | expected_result, result, source1_u, source2_c); |
| 16607 | if (dumped == 0) cod_dump(gen_code); |
| 16608 | failed++; |
| 16609 | dumped++; |
| 16610 | } |
| 16611 | } |
| 16612 | } |
| 16613 | if (verbose) printf(" done\n"); |
| 16614 | cod_free_parse_context(context); |
| 16615 | cod_code_free(gen_code); |
| 16616 | } |
| 16617 | if ((only_run_test == NULL((void*)0)) || |
| 16618 | (strcmp(only_run_test, "u<<uc") == 0)) { |
| 16619 | int i, j; |
| 16620 | static char code[] = "{\n\ |
| 16621 | unsigned int a = p1;\n\ |
| 16622 | unsigned char b = p2;\n\ |
| 16623 | return a << b;\n\ |
| 16624 | }"; |
| 16625 | |
| 16626 | unsigned int (*proc)(unsigned int a, unsigned char b); |
| 16627 | cod_parse_context context = new_cod_parse_context(); |
| 16628 | int dumped = 0; |
| 16629 | |
| 16630 | cod_code gen_code; |
| 16631 | |
| 16632 | /* test for unsigned int << unsigned char */ |
| 16633 | if (verbose) printf("test for unsigned int << unsigned char"); |
| 16634 | |
| 16635 | cod_assoc_externs(context, externs); |
| 16636 | cod_parse_for_context(extern_string, context); |
| 16637 | |
| 16638 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, unsigned char p2)", |
| 16639 | context); |
| 16640 | gen_code = cod_code_gen(code, context); |
| 16641 | proc = (unsigned int (*)(unsigned int, unsigned char))(long)gen_code->func; |
| 16642 | |
| 16643 | |
| 16644 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 16645 | unsigned int source1_u = src1u_vals[i]; |
| 16646 | for (j=0 ; j < sizeof(sh_src2c_vals)/sizeof(sh_src2c_vals[0]) ; j++) { |
| 16647 | unsigned char source2_uc = sh_src2c_vals[j]; |
| 16648 | |
| 16649 | unsigned int expected_result; |
| 16650 | unsigned int result; |
| 16651 | |
| 16652 | |
| 16653 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 16654 | |
| 16655 | expected_result = (unsigned int) (source1_u << source2_uc); |
| 16656 | |
| 16657 | result = proc(source1_u, source2_uc); |
| 16658 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 16659 | if (expected_result != result) { |
| 16660 | printf("Failed unsigned int << unsigned char test, expected %u, got %u, for %u << %u\n", |
| 16661 | expected_result, result, source1_u, source2_uc); |
| 16662 | if (dumped == 0) cod_dump(gen_code); |
| 16663 | failed++; |
| 16664 | dumped++; |
| 16665 | } |
| 16666 | } |
| 16667 | } |
| 16668 | if (verbose) printf(" done\n"); |
| 16669 | cod_free_parse_context(context); |
| 16670 | cod_code_free(gen_code); |
| 16671 | } |
| 16672 | if ((only_run_test == NULL((void*)0)) || |
| 16673 | (strcmp(only_run_test, "u<<s") == 0)) { |
| 16674 | int i, j; |
| 16675 | static char code[] = "{\n\ |
| 16676 | unsigned int a = p1;\n\ |
| 16677 | short b = p2;\n\ |
| 16678 | return a << b;\n\ |
| 16679 | }"; |
| 16680 | |
| 16681 | unsigned int (*proc)(unsigned int a, short b); |
| 16682 | cod_parse_context context = new_cod_parse_context(); |
| 16683 | int dumped = 0; |
| 16684 | |
| 16685 | cod_code gen_code; |
| 16686 | |
| 16687 | /* test for unsigned int << short */ |
| 16688 | if (verbose) printf("test for unsigned int << short"); |
| 16689 | |
| 16690 | cod_assoc_externs(context, externs); |
| 16691 | cod_parse_for_context(extern_string, context); |
| 16692 | |
| 16693 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, short p2)", |
| 16694 | context); |
| 16695 | gen_code = cod_code_gen(code, context); |
| 16696 | proc = (unsigned int (*)(unsigned int, short))(long)gen_code->func; |
| 16697 | |
| 16698 | |
| 16699 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 16700 | unsigned int source1_u = src1u_vals[i]; |
| 16701 | for (j=0 ; j < sizeof(sh_src2s_vals)/sizeof(sh_src2s_vals[0]) ; j++) { |
| 16702 | short source2_s = sh_src2s_vals[j]; |
| 16703 | |
| 16704 | unsigned int expected_result; |
| 16705 | unsigned int result; |
| 16706 | |
| 16707 | |
| 16708 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 16709 | |
| 16710 | expected_result = (unsigned int) (source1_u << source2_s); |
| 16711 | |
| 16712 | result = proc(source1_u, source2_s); |
| 16713 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 16714 | if (expected_result != result) { |
| 16715 | printf("Failed unsigned int << short test, expected %u, got %u, for %u << %d\n", |
| 16716 | expected_result, result, source1_u, source2_s); |
| 16717 | if (dumped == 0) cod_dump(gen_code); |
| 16718 | failed++; |
| 16719 | dumped++; |
| 16720 | } |
| 16721 | } |
| 16722 | } |
| 16723 | if (verbose) printf(" done\n"); |
| 16724 | cod_free_parse_context(context); |
| 16725 | cod_code_free(gen_code); |
| 16726 | } |
| 16727 | if ((only_run_test == NULL((void*)0)) || |
| 16728 | (strcmp(only_run_test, "u<<us") == 0)) { |
| 16729 | int i, j; |
| 16730 | static char code[] = "{\n\ |
| 16731 | unsigned int a = p1;\n\ |
| 16732 | unsigned short b = p2;\n\ |
| 16733 | return a << b;\n\ |
| 16734 | }"; |
| 16735 | |
| 16736 | unsigned int (*proc)(unsigned int a, unsigned short b); |
| 16737 | cod_parse_context context = new_cod_parse_context(); |
| 16738 | int dumped = 0; |
| 16739 | |
| 16740 | cod_code gen_code; |
| 16741 | |
| 16742 | /* test for unsigned int << unsigned short */ |
| 16743 | if (verbose) printf("test for unsigned int << unsigned short"); |
| 16744 | |
| 16745 | cod_assoc_externs(context, externs); |
| 16746 | cod_parse_for_context(extern_string, context); |
| 16747 | |
| 16748 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, unsigned short p2)", |
| 16749 | context); |
| 16750 | gen_code = cod_code_gen(code, context); |
| 16751 | proc = (unsigned int (*)(unsigned int, unsigned short))(long)gen_code->func; |
| 16752 | |
| 16753 | |
| 16754 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 16755 | unsigned int source1_u = src1u_vals[i]; |
| 16756 | for (j=0 ; j < sizeof(sh_src2s_vals)/sizeof(sh_src2s_vals[0]) ; j++) { |
| 16757 | unsigned short source2_us = sh_src2s_vals[j]; |
| 16758 | |
| 16759 | unsigned int expected_result; |
| 16760 | unsigned int result; |
| 16761 | |
| 16762 | |
| 16763 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 16764 | |
| 16765 | expected_result = (unsigned int) (source1_u << source2_us); |
| 16766 | |
| 16767 | result = proc(source1_u, source2_us); |
| 16768 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 16769 | if (expected_result != result) { |
| 16770 | printf("Failed unsigned int << unsigned short test, expected %u, got %u, for %u << %u\n", |
| 16771 | expected_result, result, source1_u, source2_us); |
| 16772 | if (dumped == 0) cod_dump(gen_code); |
| 16773 | failed++; |
| 16774 | dumped++; |
| 16775 | } |
| 16776 | } |
| 16777 | } |
| 16778 | if (verbose) printf(" done\n"); |
| 16779 | cod_free_parse_context(context); |
| 16780 | cod_code_free(gen_code); |
| 16781 | } |
| 16782 | if ((only_run_test == NULL((void*)0)) || |
| 16783 | (strcmp(only_run_test, "u<<i") == 0)) { |
| 16784 | int i, j; |
| 16785 | static char code[] = "{\n\ |
| 16786 | unsigned int a = p1;\n\ |
| 16787 | int b = p2;\n\ |
| 16788 | return a << b;\n\ |
| 16789 | }"; |
| 16790 | |
| 16791 | unsigned int (*proc)(unsigned int a, int b); |
| 16792 | cod_parse_context context = new_cod_parse_context(); |
| 16793 | int dumped = 0; |
| 16794 | |
| 16795 | cod_code gen_code; |
| 16796 | |
| 16797 | /* test for unsigned int << int */ |
| 16798 | if (verbose) printf("test for unsigned int << int"); |
| 16799 | |
| 16800 | cod_assoc_externs(context, externs); |
| 16801 | cod_parse_for_context(extern_string, context); |
| 16802 | |
| 16803 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, int p2)", |
| 16804 | context); |
| 16805 | gen_code = cod_code_gen(code, context); |
| 16806 | proc = (unsigned int (*)(unsigned int, int))(long)gen_code->func; |
| 16807 | |
| 16808 | |
| 16809 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 16810 | unsigned int source1_u = src1u_vals[i]; |
| 16811 | for (j=0 ; j < sizeof(sh_src2_vals)/sizeof(sh_src2_vals[0]) ; j++) { |
| 16812 | int source2_i = sh_src2_vals[j]; |
| 16813 | |
| 16814 | unsigned int expected_result; |
| 16815 | unsigned int result; |
| 16816 | |
| 16817 | |
| 16818 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 16819 | |
| 16820 | expected_result = (unsigned int) (source1_u << source2_i); |
| 16821 | |
| 16822 | result = proc(source1_u, source2_i); |
| 16823 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 16824 | if (expected_result != result) { |
| 16825 | printf("Failed unsigned int << int test, expected %u, got %u, for %u << %d\n", |
| 16826 | expected_result, result, source1_u, source2_i); |
| 16827 | if (dumped == 0) cod_dump(gen_code); |
| 16828 | failed++; |
| 16829 | dumped++; |
| 16830 | } |
| 16831 | } |
| 16832 | } |
| 16833 | if (verbose) printf(" done\n"); |
| 16834 | cod_free_parse_context(context); |
| 16835 | cod_code_free(gen_code); |
| 16836 | } |
| 16837 | if ((only_run_test == NULL((void*)0)) || |
| 16838 | (strcmp(only_run_test, "u<<u") == 0)) { |
| 16839 | int i, j; |
| 16840 | static char code[] = "{\n\ |
| 16841 | unsigned int a = p1;\n\ |
| 16842 | unsigned int b = p2;\n\ |
| 16843 | return a << b;\n\ |
| 16844 | }"; |
| 16845 | |
| 16846 | unsigned int (*proc)(unsigned int a, unsigned int b); |
| 16847 | cod_parse_context context = new_cod_parse_context(); |
| 16848 | int dumped = 0; |
| 16849 | |
| 16850 | cod_code gen_code; |
| 16851 | |
| 16852 | /* test for unsigned int << unsigned int */ |
| 16853 | if (verbose) printf("test for unsigned int << unsigned int"); |
| 16854 | |
| 16855 | cod_assoc_externs(context, externs); |
| 16856 | cod_parse_for_context(extern_string, context); |
| 16857 | |
| 16858 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, unsigned int p2)", |
| 16859 | context); |
| 16860 | gen_code = cod_code_gen(code, context); |
| 16861 | proc = (unsigned int (*)(unsigned int, unsigned int))(long)gen_code->func; |
| 16862 | |
| 16863 | |
| 16864 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 16865 | unsigned int source1_u = src1u_vals[i]; |
| 16866 | for (j=0 ; j < sizeof(sh_src2_vals)/sizeof(sh_src2_vals[0]) ; j++) { |
| 16867 | unsigned int source2_u = sh_src2_vals[j]; |
| 16868 | |
| 16869 | unsigned int expected_result; |
| 16870 | unsigned int result; |
| 16871 | |
| 16872 | |
| 16873 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 16874 | |
| 16875 | expected_result = (unsigned int) (source1_u << source2_u); |
| 16876 | |
| 16877 | result = proc(source1_u, source2_u); |
| 16878 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 16879 | if (expected_result != result) { |
| 16880 | printf("Failed unsigned int << unsigned int test, expected %u, got %u, for %u << %u\n", |
| 16881 | expected_result, result, source1_u, source2_u); |
| 16882 | if (dumped == 0) cod_dump(gen_code); |
| 16883 | failed++; |
| 16884 | dumped++; |
| 16885 | } |
| 16886 | } |
| 16887 | } |
| 16888 | if (verbose) printf(" done\n"); |
| 16889 | cod_free_parse_context(context); |
| 16890 | cod_code_free(gen_code); |
| 16891 | } |
| 16892 | if ((only_run_test == NULL((void*)0)) || |
| 16893 | (strcmp(only_run_test, "u<<ul") == 0)) { |
| 16894 | int i, j; |
| 16895 | static char code[] = "{\n\ |
| 16896 | unsigned int a = p1;\n\ |
| 16897 | unsigned long b = p2;\n\ |
| 16898 | return a << b;\n\ |
| 16899 | }"; |
| 16900 | |
| 16901 | unsigned int (*proc)(unsigned int a, unsigned long b); |
| 16902 | cod_parse_context context = new_cod_parse_context(); |
| 16903 | int dumped = 0; |
| 16904 | |
| 16905 | cod_code gen_code; |
| 16906 | |
| 16907 | /* test for unsigned int << unsigned long */ |
| 16908 | if (verbose) printf("test for unsigned int << unsigned long"); |
| 16909 | |
| 16910 | cod_assoc_externs(context, externs); |
| 16911 | cod_parse_for_context(extern_string, context); |
| 16912 | |
| 16913 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, unsigned long p2)", |
| 16914 | context); |
| 16915 | gen_code = cod_code_gen(code, context); |
| 16916 | proc = (unsigned int (*)(unsigned int, unsigned long))(long)gen_code->func; |
| 16917 | |
| 16918 | |
| 16919 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 16920 | unsigned int source1_u = src1u_vals[i]; |
| 16921 | for (j=0 ; j < sizeof(sh_src2_vals)/sizeof(sh_src2_vals[0]) ; j++) { |
| 16922 | unsigned long source2_ul = sh_src2_vals[j]; |
| 16923 | |
| 16924 | unsigned int expected_result; |
| 16925 | unsigned int result; |
| 16926 | |
| 16927 | |
| 16928 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 16929 | |
| 16930 | expected_result = (unsigned int) (source1_u << source2_ul); |
| 16931 | |
| 16932 | result = proc(source1_u, source2_ul); |
| 16933 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 16934 | if (expected_result != result) { |
| 16935 | printf("Failed unsigned int << unsigned long test, expected %u, got %u, for %u << %lu\n", |
| 16936 | expected_result, result, source1_u, source2_ul); |
| 16937 | if (dumped == 0) cod_dump(gen_code); |
| 16938 | failed++; |
| 16939 | dumped++; |
| 16940 | } |
| 16941 | } |
| 16942 | } |
| 16943 | if (verbose) printf(" done\n"); |
| 16944 | cod_free_parse_context(context); |
| 16945 | cod_code_free(gen_code); |
| 16946 | } |
| 16947 | if ((only_run_test == NULL((void*)0)) || |
| 16948 | (strcmp(only_run_test, "u<<l") == 0)) { |
| 16949 | int i, j; |
| 16950 | static char code[] = "{\n\ |
| 16951 | unsigned int a = p1;\n\ |
| 16952 | long b = p2;\n\ |
| 16953 | return a << b;\n\ |
| 16954 | }"; |
| 16955 | |
| 16956 | unsigned int (*proc)(unsigned int a, long b); |
| 16957 | cod_parse_context context = new_cod_parse_context(); |
| 16958 | int dumped = 0; |
| 16959 | |
| 16960 | cod_code gen_code; |
| 16961 | |
| 16962 | /* test for unsigned int << long */ |
| 16963 | if (verbose) printf("test for unsigned int << long"); |
| 16964 | |
| 16965 | cod_assoc_externs(context, externs); |
| 16966 | cod_parse_for_context(extern_string, context); |
| 16967 | |
| 16968 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, long p2)", |
| 16969 | context); |
| 16970 | gen_code = cod_code_gen(code, context); |
| 16971 | proc = (unsigned int (*)(unsigned int, long))(long)gen_code->func; |
| 16972 | |
| 16973 | |
| 16974 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 16975 | unsigned int source1_u = src1u_vals[i]; |
| 16976 | for (j=0 ; j < sizeof(sh_src2_vals)/sizeof(sh_src2_vals[0]) ; j++) { |
| 16977 | long source2_l = sh_src2_vals[j]; |
| 16978 | |
| 16979 | unsigned int expected_result; |
| 16980 | unsigned int result; |
| 16981 | |
| 16982 | |
| 16983 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 16984 | |
| 16985 | expected_result = (unsigned int) (source1_u << source2_l); |
| 16986 | |
| 16987 | result = proc(source1_u, source2_l); |
| 16988 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 16989 | if (expected_result != result) { |
| 16990 | printf("Failed unsigned int << long test, expected %u, got %u, for %u << %ld\n", |
| 16991 | expected_result, result, source1_u, source2_l); |
| 16992 | if (dumped == 0) cod_dump(gen_code); |
| 16993 | failed++; |
| 16994 | dumped++; |
| 16995 | } |
| 16996 | } |
| 16997 | } |
| 16998 | if (verbose) printf(" done\n"); |
| 16999 | cod_free_parse_context(context); |
| 17000 | cod_code_free(gen_code); |
| 17001 | } |
| 17002 | } |
| 17003 | void lsh_ul_tests() |
| 17004 | { |
| 17005 | if ((only_run_test == NULL((void*)0)) || |
| 17006 | (strcmp(only_run_test, "ul<<c") == 0)) { |
| 17007 | int i, j; |
| 17008 | static char code[] = "{\n\ |
| 17009 | unsigned long a = p1;\n\ |
| 17010 | signed char b = p2;\n\ |
| 17011 | return a << b;\n\ |
| 17012 | }"; |
| 17013 | |
| 17014 | unsigned long (*proc)(unsigned long a, signed char b); |
| 17015 | cod_parse_context context = new_cod_parse_context(); |
| 17016 | int dumped = 0; |
| 17017 | |
| 17018 | cod_code gen_code; |
| 17019 | |
| 17020 | /* test for unsigned long << signed char */ |
| 17021 | if (verbose) printf("test for unsigned long << signed char"); |
| 17022 | |
| 17023 | cod_assoc_externs(context, externs); |
| 17024 | cod_parse_for_context(extern_string, context); |
| 17025 | |
| 17026 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, signed char p2)", |
| 17027 | context); |
| 17028 | gen_code = cod_code_gen(code, context); |
| 17029 | proc = (unsigned long (*)(unsigned long, signed char))(long)gen_code->func; |
| 17030 | |
| 17031 | |
| 17032 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 17033 | unsigned long source1_ul = src1ul_vals[i]; |
| 17034 | for (j=0 ; j < sizeof(sh_src2c_vals)/sizeof(sh_src2c_vals[0]) ; j++) { |
| 17035 | signed char source2_c = sh_src2c_vals[j]; |
| 17036 | |
| 17037 | unsigned long expected_result; |
| 17038 | unsigned long result; |
| 17039 | |
| 17040 | |
| 17041 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 17042 | |
| 17043 | expected_result = (unsigned long) (source1_ul << source2_c); |
| 17044 | |
| 17045 | result = proc(source1_ul, source2_c); |
| 17046 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 17047 | if (expected_result != result) { |
| 17048 | printf("Failed unsigned long << signed char test, expected %lu, got %lu, for %lu << %d\n", |
| 17049 | expected_result, result, source1_ul, source2_c); |
| 17050 | if (dumped == 0) cod_dump(gen_code); |
| 17051 | failed++; |
| 17052 | dumped++; |
| 17053 | } |
| 17054 | } |
| 17055 | } |
| 17056 | if (verbose) printf(" done\n"); |
| 17057 | cod_free_parse_context(context); |
| 17058 | cod_code_free(gen_code); |
| 17059 | } |
| 17060 | if ((only_run_test == NULL((void*)0)) || |
| 17061 | (strcmp(only_run_test, "ul<<uc") == 0)) { |
| 17062 | int i, j; |
| 17063 | static char code[] = "{\n\ |
| 17064 | unsigned long a = p1;\n\ |
| 17065 | unsigned char b = p2;\n\ |
| 17066 | return a << b;\n\ |
| 17067 | }"; |
| 17068 | |
| 17069 | unsigned long (*proc)(unsigned long a, unsigned char b); |
| 17070 | cod_parse_context context = new_cod_parse_context(); |
| 17071 | int dumped = 0; |
| 17072 | |
| 17073 | cod_code gen_code; |
| 17074 | |
| 17075 | /* test for unsigned long << unsigned char */ |
| 17076 | if (verbose) printf("test for unsigned long << unsigned char"); |
| 17077 | |
| 17078 | cod_assoc_externs(context, externs); |
| 17079 | cod_parse_for_context(extern_string, context); |
| 17080 | |
| 17081 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, unsigned char p2)", |
| 17082 | context); |
| 17083 | gen_code = cod_code_gen(code, context); |
| 17084 | proc = (unsigned long (*)(unsigned long, unsigned char))(long)gen_code->func; |
| 17085 | |
| 17086 | |
| 17087 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 17088 | unsigned long source1_ul = src1ul_vals[i]; |
| 17089 | for (j=0 ; j < sizeof(sh_src2c_vals)/sizeof(sh_src2c_vals[0]) ; j++) { |
| 17090 | unsigned char source2_uc = sh_src2c_vals[j]; |
| 17091 | |
| 17092 | unsigned long expected_result; |
| 17093 | unsigned long result; |
| 17094 | |
| 17095 | |
| 17096 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 17097 | |
| 17098 | expected_result = (unsigned long) (source1_ul << source2_uc); |
| 17099 | |
| 17100 | result = proc(source1_ul, source2_uc); |
| 17101 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 17102 | if (expected_result != result) { |
| 17103 | printf("Failed unsigned long << unsigned char test, expected %lu, got %lu, for %lu << %u\n", |
| 17104 | expected_result, result, source1_ul, source2_uc); |
| 17105 | if (dumped == 0) cod_dump(gen_code); |
| 17106 | failed++; |
| 17107 | dumped++; |
| 17108 | } |
| 17109 | } |
| 17110 | } |
| 17111 | if (verbose) printf(" done\n"); |
| 17112 | cod_free_parse_context(context); |
| 17113 | cod_code_free(gen_code); |
| 17114 | } |
| 17115 | if ((only_run_test == NULL((void*)0)) || |
| 17116 | (strcmp(only_run_test, "ul<<s") == 0)) { |
| 17117 | int i, j; |
| 17118 | static char code[] = "{\n\ |
| 17119 | unsigned long a = p1;\n\ |
| 17120 | short b = p2;\n\ |
| 17121 | return a << b;\n\ |
| 17122 | }"; |
| 17123 | |
| 17124 | unsigned long (*proc)(unsigned long a, short b); |
| 17125 | cod_parse_context context = new_cod_parse_context(); |
| 17126 | int dumped = 0; |
| 17127 | |
| 17128 | cod_code gen_code; |
| 17129 | |
| 17130 | /* test for unsigned long << short */ |
| 17131 | if (verbose) printf("test for unsigned long << short"); |
| 17132 | |
| 17133 | cod_assoc_externs(context, externs); |
| 17134 | cod_parse_for_context(extern_string, context); |
| 17135 | |
| 17136 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, short p2)", |
| 17137 | context); |
| 17138 | gen_code = cod_code_gen(code, context); |
| 17139 | proc = (unsigned long (*)(unsigned long, short))(long)gen_code->func; |
| 17140 | |
| 17141 | |
| 17142 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 17143 | unsigned long source1_ul = src1ul_vals[i]; |
| 17144 | for (j=0 ; j < sizeof(sh_src2s_vals)/sizeof(sh_src2s_vals[0]) ; j++) { |
| 17145 | short source2_s = sh_src2s_vals[j]; |
| 17146 | |
| 17147 | unsigned long expected_result; |
| 17148 | unsigned long result; |
| 17149 | |
| 17150 | |
| 17151 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 17152 | |
| 17153 | expected_result = (unsigned long) (source1_ul << source2_s); |
| 17154 | |
| 17155 | result = proc(source1_ul, source2_s); |
| 17156 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 17157 | if (expected_result != result) { |
| 17158 | printf("Failed unsigned long << short test, expected %lu, got %lu, for %lu << %d\n", |
| 17159 | expected_result, result, source1_ul, source2_s); |
| 17160 | if (dumped == 0) cod_dump(gen_code); |
| 17161 | failed++; |
| 17162 | dumped++; |
| 17163 | } |
| 17164 | } |
| 17165 | } |
| 17166 | if (verbose) printf(" done\n"); |
| 17167 | cod_free_parse_context(context); |
| 17168 | cod_code_free(gen_code); |
| 17169 | } |
| 17170 | if ((only_run_test == NULL((void*)0)) || |
| 17171 | (strcmp(only_run_test, "ul<<us") == 0)) { |
| 17172 | int i, j; |
| 17173 | static char code[] = "{\n\ |
| 17174 | unsigned long a = p1;\n\ |
| 17175 | unsigned short b = p2;\n\ |
| 17176 | return a << b;\n\ |
| 17177 | }"; |
| 17178 | |
| 17179 | unsigned long (*proc)(unsigned long a, unsigned short b); |
| 17180 | cod_parse_context context = new_cod_parse_context(); |
| 17181 | int dumped = 0; |
| 17182 | |
| 17183 | cod_code gen_code; |
| 17184 | |
| 17185 | /* test for unsigned long << unsigned short */ |
| 17186 | if (verbose) printf("test for unsigned long << unsigned short"); |
| 17187 | |
| 17188 | cod_assoc_externs(context, externs); |
| 17189 | cod_parse_for_context(extern_string, context); |
| 17190 | |
| 17191 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, unsigned short p2)", |
| 17192 | context); |
| 17193 | gen_code = cod_code_gen(code, context); |
| 17194 | proc = (unsigned long (*)(unsigned long, unsigned short))(long)gen_code->func; |
| 17195 | |
| 17196 | |
| 17197 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 17198 | unsigned long source1_ul = src1ul_vals[i]; |
| 17199 | for (j=0 ; j < sizeof(sh_src2s_vals)/sizeof(sh_src2s_vals[0]) ; j++) { |
| 17200 | unsigned short source2_us = sh_src2s_vals[j]; |
| 17201 | |
| 17202 | unsigned long expected_result; |
| 17203 | unsigned long result; |
| 17204 | |
| 17205 | |
| 17206 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 17207 | |
| 17208 | expected_result = (unsigned long) (source1_ul << source2_us); |
| 17209 | |
| 17210 | result = proc(source1_ul, source2_us); |
| 17211 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 17212 | if (expected_result != result) { |
| 17213 | printf("Failed unsigned long << unsigned short test, expected %lu, got %lu, for %lu << %u\n", |
| 17214 | expected_result, result, source1_ul, source2_us); |
| 17215 | if (dumped == 0) cod_dump(gen_code); |
| 17216 | failed++; |
| 17217 | dumped++; |
| 17218 | } |
| 17219 | } |
| 17220 | } |
| 17221 | if (verbose) printf(" done\n"); |
| 17222 | cod_free_parse_context(context); |
| 17223 | cod_code_free(gen_code); |
| 17224 | } |
| 17225 | if ((only_run_test == NULL((void*)0)) || |
| 17226 | (strcmp(only_run_test, "ul<<i") == 0)) { |
| 17227 | int i, j; |
| 17228 | static char code[] = "{\n\ |
| 17229 | unsigned long a = p1;\n\ |
| 17230 | int b = p2;\n\ |
| 17231 | return a << b;\n\ |
| 17232 | }"; |
| 17233 | |
| 17234 | unsigned long (*proc)(unsigned long a, int b); |
| 17235 | cod_parse_context context = new_cod_parse_context(); |
| 17236 | int dumped = 0; |
| 17237 | |
| 17238 | cod_code gen_code; |
| 17239 | |
| 17240 | /* test for unsigned long << int */ |
| 17241 | if (verbose) printf("test for unsigned long << int"); |
| 17242 | |
| 17243 | cod_assoc_externs(context, externs); |
| 17244 | cod_parse_for_context(extern_string, context); |
| 17245 | |
| 17246 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, int p2)", |
| 17247 | context); |
| 17248 | gen_code = cod_code_gen(code, context); |
| 17249 | proc = (unsigned long (*)(unsigned long, int))(long)gen_code->func; |
| 17250 | |
| 17251 | |
| 17252 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 17253 | unsigned long source1_ul = src1ul_vals[i]; |
| 17254 | for (j=0 ; j < sizeof(sh_src2_vals)/sizeof(sh_src2_vals[0]) ; j++) { |
| 17255 | int source2_i = sh_src2_vals[j]; |
| 17256 | |
| 17257 | unsigned long expected_result; |
| 17258 | unsigned long result; |
| 17259 | |
| 17260 | |
| 17261 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 17262 | |
| 17263 | expected_result = (unsigned long) (source1_ul << source2_i); |
| 17264 | |
| 17265 | result = proc(source1_ul, source2_i); |
| 17266 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 17267 | if (expected_result != result) { |
| 17268 | printf("Failed unsigned long << int test, expected %lu, got %lu, for %lu << %d\n", |
| 17269 | expected_result, result, source1_ul, source2_i); |
| 17270 | if (dumped == 0) cod_dump(gen_code); |
| 17271 | failed++; |
| 17272 | dumped++; |
| 17273 | } |
| 17274 | } |
| 17275 | } |
| 17276 | if (verbose) printf(" done\n"); |
| 17277 | cod_free_parse_context(context); |
| 17278 | cod_code_free(gen_code); |
| 17279 | } |
| 17280 | if ((only_run_test == NULL((void*)0)) || |
| 17281 | (strcmp(only_run_test, "ul<<u") == 0)) { |
| 17282 | int i, j; |
| 17283 | static char code[] = "{\n\ |
| 17284 | unsigned long a = p1;\n\ |
| 17285 | unsigned int b = p2;\n\ |
| 17286 | return a << b;\n\ |
| 17287 | }"; |
| 17288 | |
| 17289 | unsigned long (*proc)(unsigned long a, unsigned int b); |
| 17290 | cod_parse_context context = new_cod_parse_context(); |
| 17291 | int dumped = 0; |
| 17292 | |
| 17293 | cod_code gen_code; |
| 17294 | |
| 17295 | /* test for unsigned long << unsigned int */ |
| 17296 | if (verbose) printf("test for unsigned long << unsigned int"); |
| 17297 | |
| 17298 | cod_assoc_externs(context, externs); |
| 17299 | cod_parse_for_context(extern_string, context); |
| 17300 | |
| 17301 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, unsigned int p2)", |
| 17302 | context); |
| 17303 | gen_code = cod_code_gen(code, context); |
| 17304 | proc = (unsigned long (*)(unsigned long, unsigned int))(long)gen_code->func; |
| 17305 | |
| 17306 | |
| 17307 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 17308 | unsigned long source1_ul = src1ul_vals[i]; |
| 17309 | for (j=0 ; j < sizeof(sh_src2_vals)/sizeof(sh_src2_vals[0]) ; j++) { |
| 17310 | unsigned int source2_u = sh_src2_vals[j]; |
| 17311 | |
| 17312 | unsigned long expected_result; |
| 17313 | unsigned long result; |
| 17314 | |
| 17315 | |
| 17316 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 17317 | |
| 17318 | expected_result = (unsigned long) (source1_ul << source2_u); |
| 17319 | |
| 17320 | result = proc(source1_ul, source2_u); |
| 17321 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 17322 | if (expected_result != result) { |
| 17323 | printf("Failed unsigned long << unsigned int test, expected %lu, got %lu, for %lu << %u\n", |
| 17324 | expected_result, result, source1_ul, source2_u); |
| 17325 | if (dumped == 0) cod_dump(gen_code); |
| 17326 | failed++; |
| 17327 | dumped++; |
| 17328 | } |
| 17329 | } |
| 17330 | } |
| 17331 | if (verbose) printf(" done\n"); |
| 17332 | cod_free_parse_context(context); |
| 17333 | cod_code_free(gen_code); |
| 17334 | } |
| 17335 | if ((only_run_test == NULL((void*)0)) || |
| 17336 | (strcmp(only_run_test, "ul<<ul") == 0)) { |
| 17337 | int i, j; |
| 17338 | static char code[] = "{\n\ |
| 17339 | unsigned long a = p1;\n\ |
| 17340 | unsigned long b = p2;\n\ |
| 17341 | return a << b;\n\ |
| 17342 | }"; |
| 17343 | |
| 17344 | unsigned long (*proc)(unsigned long a, unsigned long b); |
| 17345 | cod_parse_context context = new_cod_parse_context(); |
| 17346 | int dumped = 0; |
| 17347 | |
| 17348 | cod_code gen_code; |
| 17349 | |
| 17350 | /* test for unsigned long << unsigned long */ |
| 17351 | if (verbose) printf("test for unsigned long << unsigned long"); |
| 17352 | |
| 17353 | cod_assoc_externs(context, externs); |
| 17354 | cod_parse_for_context(extern_string, context); |
| 17355 | |
| 17356 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, unsigned long p2)", |
| 17357 | context); |
| 17358 | gen_code = cod_code_gen(code, context); |
| 17359 | proc = (unsigned long (*)(unsigned long, unsigned long))(long)gen_code->func; |
| 17360 | |
| 17361 | |
| 17362 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 17363 | unsigned long source1_ul = src1ul_vals[i]; |
| 17364 | for (j=0 ; j < sizeof(sh_src2_vals)/sizeof(sh_src2_vals[0]) ; j++) { |
| 17365 | unsigned long source2_ul = sh_src2_vals[j]; |
| 17366 | |
| 17367 | unsigned long expected_result; |
| 17368 | unsigned long result; |
| 17369 | |
| 17370 | |
| 17371 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 17372 | |
| 17373 | expected_result = (unsigned long) (source1_ul << source2_ul); |
| 17374 | |
| 17375 | result = proc(source1_ul, source2_ul); |
| 17376 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 17377 | if (expected_result != result) { |
| 17378 | printf("Failed unsigned long << unsigned long test, expected %lu, got %lu, for %lu << %lu\n", |
| 17379 | expected_result, result, source1_ul, source2_ul); |
| 17380 | if (dumped == 0) cod_dump(gen_code); |
| 17381 | failed++; |
| 17382 | dumped++; |
| 17383 | } |
| 17384 | } |
| 17385 | } |
| 17386 | if (verbose) printf(" done\n"); |
| 17387 | cod_free_parse_context(context); |
| 17388 | cod_code_free(gen_code); |
| 17389 | } |
| 17390 | if ((only_run_test == NULL((void*)0)) || |
| 17391 | (strcmp(only_run_test, "ul<<l") == 0)) { |
| 17392 | int i, j; |
| 17393 | static char code[] = "{\n\ |
| 17394 | unsigned long a = p1;\n\ |
| 17395 | long b = p2;\n\ |
| 17396 | return a << b;\n\ |
| 17397 | }"; |
| 17398 | |
| 17399 | unsigned long (*proc)(unsigned long a, long b); |
| 17400 | cod_parse_context context = new_cod_parse_context(); |
| 17401 | int dumped = 0; |
| 17402 | |
| 17403 | cod_code gen_code; |
| 17404 | |
| 17405 | /* test for unsigned long << long */ |
| 17406 | if (verbose) printf("test for unsigned long << long"); |
| 17407 | |
| 17408 | cod_assoc_externs(context, externs); |
| 17409 | cod_parse_for_context(extern_string, context); |
| 17410 | |
| 17411 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, long p2)", |
| 17412 | context); |
| 17413 | gen_code = cod_code_gen(code, context); |
| 17414 | proc = (unsigned long (*)(unsigned long, long))(long)gen_code->func; |
| 17415 | |
| 17416 | |
| 17417 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 17418 | unsigned long source1_ul = src1ul_vals[i]; |
| 17419 | for (j=0 ; j < sizeof(sh_src2_vals)/sizeof(sh_src2_vals[0]) ; j++) { |
| 17420 | long source2_l = sh_src2_vals[j]; |
| 17421 | |
| 17422 | unsigned long expected_result; |
| 17423 | unsigned long result; |
| 17424 | |
| 17425 | |
| 17426 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 17427 | |
| 17428 | expected_result = (unsigned long) (source1_ul << source2_l); |
| 17429 | |
| 17430 | result = proc(source1_ul, source2_l); |
| 17431 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 17432 | if (expected_result != result) { |
| 17433 | printf("Failed unsigned long << long test, expected %lu, got %lu, for %lu << %ld\n", |
| 17434 | expected_result, result, source1_ul, source2_l); |
| 17435 | if (dumped == 0) cod_dump(gen_code); |
| 17436 | failed++; |
| 17437 | dumped++; |
| 17438 | } |
| 17439 | } |
| 17440 | } |
| 17441 | if (verbose) printf(" done\n"); |
| 17442 | cod_free_parse_context(context); |
| 17443 | cod_code_free(gen_code); |
| 17444 | } |
| 17445 | } |
| 17446 | void lsh_l_tests() |
| 17447 | { |
| 17448 | if ((only_run_test == NULL((void*)0)) || |
| 17449 | (strcmp(only_run_test, "l<<c") == 0)) { |
| 17450 | int i, j; |
| 17451 | static char code[] = "{\n\ |
| 17452 | long a = p1;\n\ |
| 17453 | signed char b = p2;\n\ |
| 17454 | return a << b;\n\ |
| 17455 | }"; |
| 17456 | |
| 17457 | long (*proc)(long a, signed char b); |
| 17458 | cod_parse_context context = new_cod_parse_context(); |
| 17459 | int dumped = 0; |
| 17460 | |
| 17461 | cod_code gen_code; |
| 17462 | |
| 17463 | /* test for long << signed char */ |
| 17464 | if (verbose) printf("test for long << signed char"); |
| 17465 | |
| 17466 | cod_assoc_externs(context, externs); |
| 17467 | cod_parse_for_context(extern_string, context); |
| 17468 | |
| 17469 | cod_subroutine_declaration("long proc(long p1, signed char p2)", |
| 17470 | context); |
| 17471 | gen_code = cod_code_gen(code, context); |
| 17472 | proc = (long (*)(long, signed char))(long)gen_code->func; |
| 17473 | |
| 17474 | |
| 17475 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 17476 | long source1_l = src1l_vals[i]; |
| 17477 | for (j=0 ; j < sizeof(sh_src2c_vals)/sizeof(sh_src2c_vals[0]) ; j++) { |
| 17478 | signed char source2_c = sh_src2c_vals[j]; |
| 17479 | |
| 17480 | long expected_result; |
| 17481 | long result; |
| 17482 | |
| 17483 | |
| 17484 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 17485 | |
| 17486 | expected_result = (long) (source1_l << source2_c); |
| 17487 | |
| 17488 | result = proc(source1_l, source2_c); |
| 17489 | if (expected_result != result) { |
| 17490 | printf("Failed long << signed char test, expected %ld, got %ld, for %ld << %d\n", |
| 17491 | expected_result, result, source1_l, source2_c); |
| 17492 | if (dumped == 0) cod_dump(gen_code); |
| 17493 | failed++; |
| 17494 | dumped++; |
| 17495 | } |
| 17496 | } |
| 17497 | } |
| 17498 | if (verbose) printf(" done\n"); |
| 17499 | cod_free_parse_context(context); |
| 17500 | cod_code_free(gen_code); |
| 17501 | } |
| 17502 | if ((only_run_test == NULL((void*)0)) || |
| 17503 | (strcmp(only_run_test, "l<<uc") == 0)) { |
| 17504 | int i, j; |
| 17505 | static char code[] = "{\n\ |
| 17506 | long a = p1;\n\ |
| 17507 | unsigned char b = p2;\n\ |
| 17508 | return a << b;\n\ |
| 17509 | }"; |
| 17510 | |
| 17511 | long (*proc)(long a, unsigned char b); |
| 17512 | cod_parse_context context = new_cod_parse_context(); |
| 17513 | int dumped = 0; |
| 17514 | |
| 17515 | cod_code gen_code; |
| 17516 | |
| 17517 | /* test for long << unsigned char */ |
| 17518 | if (verbose) printf("test for long << unsigned char"); |
| 17519 | |
| 17520 | cod_assoc_externs(context, externs); |
| 17521 | cod_parse_for_context(extern_string, context); |
| 17522 | |
| 17523 | cod_subroutine_declaration("long proc(long p1, unsigned char p2)", |
| 17524 | context); |
| 17525 | gen_code = cod_code_gen(code, context); |
| 17526 | proc = (long (*)(long, unsigned char))(long)gen_code->func; |
| 17527 | |
| 17528 | |
| 17529 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 17530 | long source1_l = src1l_vals[i]; |
| 17531 | for (j=0 ; j < sizeof(sh_src2c_vals)/sizeof(sh_src2c_vals[0]) ; j++) { |
| 17532 | unsigned char source2_uc = sh_src2c_vals[j]; |
| 17533 | |
| 17534 | long expected_result; |
| 17535 | long result; |
| 17536 | |
| 17537 | |
| 17538 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 17539 | |
| 17540 | expected_result = (long) (source1_l << source2_uc); |
| 17541 | |
| 17542 | result = proc(source1_l, source2_uc); |
| 17543 | if (expected_result != result) { |
| 17544 | printf("Failed long << unsigned char test, expected %ld, got %ld, for %ld << %u\n", |
| 17545 | expected_result, result, source1_l, source2_uc); |
| 17546 | if (dumped == 0) cod_dump(gen_code); |
| 17547 | failed++; |
| 17548 | dumped++; |
| 17549 | } |
| 17550 | } |
| 17551 | } |
| 17552 | if (verbose) printf(" done\n"); |
| 17553 | cod_free_parse_context(context); |
| 17554 | cod_code_free(gen_code); |
| 17555 | } |
| 17556 | if ((only_run_test == NULL((void*)0)) || |
| 17557 | (strcmp(only_run_test, "l<<s") == 0)) { |
| 17558 | int i, j; |
| 17559 | static char code[] = "{\n\ |
| 17560 | long a = p1;\n\ |
| 17561 | short b = p2;\n\ |
| 17562 | return a << b;\n\ |
| 17563 | }"; |
| 17564 | |
| 17565 | long (*proc)(long a, short b); |
| 17566 | cod_parse_context context = new_cod_parse_context(); |
| 17567 | int dumped = 0; |
| 17568 | |
| 17569 | cod_code gen_code; |
| 17570 | |
| 17571 | /* test for long << short */ |
| 17572 | if (verbose) printf("test for long << short"); |
| 17573 | |
| 17574 | cod_assoc_externs(context, externs); |
| 17575 | cod_parse_for_context(extern_string, context); |
| 17576 | |
| 17577 | cod_subroutine_declaration("long proc(long p1, short p2)", |
| 17578 | context); |
| 17579 | gen_code = cod_code_gen(code, context); |
| 17580 | proc = (long (*)(long, short))(long)gen_code->func; |
| 17581 | |
| 17582 | |
| 17583 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 17584 | long source1_l = src1l_vals[i]; |
| 17585 | for (j=0 ; j < sizeof(sh_src2s_vals)/sizeof(sh_src2s_vals[0]) ; j++) { |
| 17586 | short source2_s = sh_src2s_vals[j]; |
| 17587 | |
| 17588 | long expected_result; |
| 17589 | long result; |
| 17590 | |
| 17591 | |
| 17592 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 17593 | |
| 17594 | expected_result = (long) (source1_l << source2_s); |
| 17595 | |
| 17596 | result = proc(source1_l, source2_s); |
| 17597 | if (expected_result != result) { |
| 17598 | printf("Failed long << short test, expected %ld, got %ld, for %ld << %d\n", |
| 17599 | expected_result, result, source1_l, source2_s); |
| 17600 | if (dumped == 0) cod_dump(gen_code); |
| 17601 | failed++; |
| 17602 | dumped++; |
| 17603 | } |
| 17604 | } |
| 17605 | } |
| 17606 | if (verbose) printf(" done\n"); |
| 17607 | cod_free_parse_context(context); |
| 17608 | cod_code_free(gen_code); |
| 17609 | } |
| 17610 | if ((only_run_test == NULL((void*)0)) || |
| 17611 | (strcmp(only_run_test, "l<<us") == 0)) { |
| 17612 | int i, j; |
| 17613 | static char code[] = "{\n\ |
| 17614 | long a = p1;\n\ |
| 17615 | unsigned short b = p2;\n\ |
| 17616 | return a << b;\n\ |
| 17617 | }"; |
| 17618 | |
| 17619 | long (*proc)(long a, unsigned short b); |
| 17620 | cod_parse_context context = new_cod_parse_context(); |
| 17621 | int dumped = 0; |
| 17622 | |
| 17623 | cod_code gen_code; |
| 17624 | |
| 17625 | /* test for long << unsigned short */ |
| 17626 | if (verbose) printf("test for long << unsigned short"); |
| 17627 | |
| 17628 | cod_assoc_externs(context, externs); |
| 17629 | cod_parse_for_context(extern_string, context); |
| 17630 | |
| 17631 | cod_subroutine_declaration("long proc(long p1, unsigned short p2)", |
| 17632 | context); |
| 17633 | gen_code = cod_code_gen(code, context); |
| 17634 | proc = (long (*)(long, unsigned short))(long)gen_code->func; |
| 17635 | |
| 17636 | |
| 17637 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 17638 | long source1_l = src1l_vals[i]; |
| 17639 | for (j=0 ; j < sizeof(sh_src2s_vals)/sizeof(sh_src2s_vals[0]) ; j++) { |
| 17640 | unsigned short source2_us = sh_src2s_vals[j]; |
| 17641 | |
| 17642 | long expected_result; |
| 17643 | long result; |
| 17644 | |
| 17645 | |
| 17646 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 17647 | |
| 17648 | expected_result = (long) (source1_l << source2_us); |
| 17649 | |
| 17650 | result = proc(source1_l, source2_us); |
| 17651 | if (expected_result != result) { |
| 17652 | printf("Failed long << unsigned short test, expected %ld, got %ld, for %ld << %u\n", |
| 17653 | expected_result, result, source1_l, source2_us); |
| 17654 | if (dumped == 0) cod_dump(gen_code); |
| 17655 | failed++; |
| 17656 | dumped++; |
| 17657 | } |
| 17658 | } |
| 17659 | } |
| 17660 | if (verbose) printf(" done\n"); |
| 17661 | cod_free_parse_context(context); |
| 17662 | cod_code_free(gen_code); |
| 17663 | } |
| 17664 | if ((only_run_test == NULL((void*)0)) || |
| 17665 | (strcmp(only_run_test, "l<<i") == 0)) { |
| 17666 | int i, j; |
| 17667 | static char code[] = "{\n\ |
| 17668 | long a = p1;\n\ |
| 17669 | int b = p2;\n\ |
| 17670 | return a << b;\n\ |
| 17671 | }"; |
| 17672 | |
| 17673 | long (*proc)(long a, int b); |
| 17674 | cod_parse_context context = new_cod_parse_context(); |
| 17675 | int dumped = 0; |
| 17676 | |
| 17677 | cod_code gen_code; |
| 17678 | |
| 17679 | /* test for long << int */ |
| 17680 | if (verbose) printf("test for long << int"); |
| 17681 | |
| 17682 | cod_assoc_externs(context, externs); |
| 17683 | cod_parse_for_context(extern_string, context); |
| 17684 | |
| 17685 | cod_subroutine_declaration("long proc(long p1, int p2)", |
| 17686 | context); |
| 17687 | gen_code = cod_code_gen(code, context); |
| 17688 | proc = (long (*)(long, int))(long)gen_code->func; |
| 17689 | |
| 17690 | |
| 17691 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 17692 | long source1_l = src1l_vals[i]; |
| 17693 | for (j=0 ; j < sizeof(sh_src2_vals)/sizeof(sh_src2_vals[0]) ; j++) { |
| 17694 | int source2_i = sh_src2_vals[j]; |
| 17695 | |
| 17696 | long expected_result; |
| 17697 | long result; |
| 17698 | |
| 17699 | |
| 17700 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 17701 | |
| 17702 | expected_result = (long) (source1_l << source2_i); |
| 17703 | |
| 17704 | result = proc(source1_l, source2_i); |
| 17705 | if (expected_result != result) { |
| 17706 | printf("Failed long << int test, expected %ld, got %ld, for %ld << %d\n", |
| 17707 | expected_result, result, source1_l, source2_i); |
| 17708 | if (dumped == 0) cod_dump(gen_code); |
| 17709 | failed++; |
| 17710 | dumped++; |
| 17711 | } |
| 17712 | } |
| 17713 | } |
| 17714 | if (verbose) printf(" done\n"); |
| 17715 | cod_free_parse_context(context); |
| 17716 | cod_code_free(gen_code); |
| 17717 | } |
| 17718 | if ((only_run_test == NULL((void*)0)) || |
| 17719 | (strcmp(only_run_test, "l<<u") == 0)) { |
| 17720 | int i, j; |
| 17721 | static char code[] = "{\n\ |
| 17722 | long a = p1;\n\ |
| 17723 | unsigned int b = p2;\n\ |
| 17724 | return a << b;\n\ |
| 17725 | }"; |
| 17726 | |
| 17727 | long (*proc)(long a, unsigned int b); |
| 17728 | cod_parse_context context = new_cod_parse_context(); |
| 17729 | int dumped = 0; |
| 17730 | |
| 17731 | cod_code gen_code; |
| 17732 | |
| 17733 | /* test for long << unsigned int */ |
| 17734 | if (verbose) printf("test for long << unsigned int"); |
| 17735 | |
| 17736 | cod_assoc_externs(context, externs); |
| 17737 | cod_parse_for_context(extern_string, context); |
| 17738 | |
| 17739 | cod_subroutine_declaration("long proc(long p1, unsigned int p2)", |
| 17740 | context); |
| 17741 | gen_code = cod_code_gen(code, context); |
| 17742 | proc = (long (*)(long, unsigned int))(long)gen_code->func; |
| 17743 | |
| 17744 | |
| 17745 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 17746 | long source1_l = src1l_vals[i]; |
| 17747 | for (j=0 ; j < sizeof(sh_src2_vals)/sizeof(sh_src2_vals[0]) ; j++) { |
| 17748 | unsigned int source2_u = sh_src2_vals[j]; |
| 17749 | |
| 17750 | long expected_result; |
| 17751 | long result; |
| 17752 | |
| 17753 | |
| 17754 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 17755 | |
| 17756 | expected_result = (long) (source1_l << source2_u); |
| 17757 | |
| 17758 | result = proc(source1_l, source2_u); |
| 17759 | if (expected_result != result) { |
| 17760 | printf("Failed long << unsigned int test, expected %ld, got %ld, for %ld << %u\n", |
| 17761 | expected_result, result, source1_l, source2_u); |
| 17762 | if (dumped == 0) cod_dump(gen_code); |
| 17763 | failed++; |
| 17764 | dumped++; |
| 17765 | } |
| 17766 | } |
| 17767 | } |
| 17768 | if (verbose) printf(" done\n"); |
| 17769 | cod_free_parse_context(context); |
| 17770 | cod_code_free(gen_code); |
| 17771 | } |
| 17772 | if ((only_run_test == NULL((void*)0)) || |
| 17773 | (strcmp(only_run_test, "l<<ul") == 0)) { |
| 17774 | int i, j; |
| 17775 | static char code[] = "{\n\ |
| 17776 | long a = p1;\n\ |
| 17777 | unsigned long b = p2;\n\ |
| 17778 | return a << b;\n\ |
| 17779 | }"; |
| 17780 | |
| 17781 | long (*proc)(long a, unsigned long b); |
| 17782 | cod_parse_context context = new_cod_parse_context(); |
| 17783 | int dumped = 0; |
| 17784 | |
| 17785 | cod_code gen_code; |
| 17786 | |
| 17787 | /* test for long << unsigned long */ |
| 17788 | if (verbose) printf("test for long << unsigned long"); |
| 17789 | |
| 17790 | cod_assoc_externs(context, externs); |
| 17791 | cod_parse_for_context(extern_string, context); |
| 17792 | |
| 17793 | cod_subroutine_declaration("long proc(long p1, unsigned long p2)", |
| 17794 | context); |
| 17795 | gen_code = cod_code_gen(code, context); |
| 17796 | proc = (long (*)(long, unsigned long))(long)gen_code->func; |
| 17797 | |
| 17798 | |
| 17799 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 17800 | long source1_l = src1l_vals[i]; |
| 17801 | for (j=0 ; j < sizeof(sh_src2_vals)/sizeof(sh_src2_vals[0]) ; j++) { |
| 17802 | unsigned long source2_ul = sh_src2_vals[j]; |
| 17803 | |
| 17804 | long expected_result; |
| 17805 | long result; |
| 17806 | |
| 17807 | |
| 17808 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 17809 | |
| 17810 | expected_result = (long) (source1_l << source2_ul); |
| 17811 | |
| 17812 | result = proc(source1_l, source2_ul); |
| 17813 | if (expected_result != result) { |
| 17814 | printf("Failed long << unsigned long test, expected %ld, got %ld, for %ld << %lu\n", |
| 17815 | expected_result, result, source1_l, source2_ul); |
| 17816 | if (dumped == 0) cod_dump(gen_code); |
| 17817 | failed++; |
| 17818 | dumped++; |
| 17819 | } |
| 17820 | } |
| 17821 | } |
| 17822 | if (verbose) printf(" done\n"); |
| 17823 | cod_free_parse_context(context); |
| 17824 | cod_code_free(gen_code); |
| 17825 | } |
| 17826 | if ((only_run_test == NULL((void*)0)) || |
| 17827 | (strcmp(only_run_test, "l<<l") == 0)) { |
| 17828 | int i, j; |
| 17829 | static char code[] = "{\n\ |
| 17830 | long a = p1;\n\ |
| 17831 | long b = p2;\n\ |
| 17832 | return a << b;\n\ |
| 17833 | }"; |
| 17834 | |
| 17835 | long (*proc)(long a, long b); |
| 17836 | cod_parse_context context = new_cod_parse_context(); |
| 17837 | int dumped = 0; |
| 17838 | |
| 17839 | cod_code gen_code; |
| 17840 | |
| 17841 | /* test for long << long */ |
| 17842 | if (verbose) printf("test for long << long"); |
| 17843 | |
| 17844 | cod_assoc_externs(context, externs); |
| 17845 | cod_parse_for_context(extern_string, context); |
| 17846 | |
| 17847 | cod_subroutine_declaration("long proc(long p1, long p2)", |
| 17848 | context); |
| 17849 | gen_code = cod_code_gen(code, context); |
| 17850 | proc = (long (*)(long, long))(long)gen_code->func; |
| 17851 | |
| 17852 | |
| 17853 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 17854 | long source1_l = src1l_vals[i]; |
| 17855 | for (j=0 ; j < sizeof(sh_src2_vals)/sizeof(sh_src2_vals[0]) ; j++) { |
| 17856 | long source2_l = sh_src2_vals[j]; |
| 17857 | |
| 17858 | long expected_result; |
| 17859 | long result; |
| 17860 | |
| 17861 | |
| 17862 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 17863 | |
| 17864 | expected_result = (long) (source1_l << source2_l); |
| 17865 | |
| 17866 | result = proc(source1_l, source2_l); |
| 17867 | if (expected_result != result) { |
| 17868 | printf("Failed long << long test, expected %ld, got %ld, for %ld << %ld\n", |
| 17869 | expected_result, result, source1_l, source2_l); |
| 17870 | if (dumped == 0) cod_dump(gen_code); |
| 17871 | failed++; |
| 17872 | dumped++; |
| 17873 | } |
| 17874 | } |
| 17875 | } |
| 17876 | if (verbose) printf(" done\n"); |
| 17877 | cod_free_parse_context(context); |
| 17878 | cod_code_free(gen_code); |
| 17879 | } |
| 17880 | } |
| 17881 | void rsh_c_tests() |
| 17882 | { |
| 17883 | if ((only_run_test == NULL((void*)0)) || |
| 17884 | (strcmp(only_run_test, "c>>c") == 0)) { |
| 17885 | int i, j; |
| 17886 | static char code[] = "{\n\ |
| 17887 | signed char a = p1;\n\ |
| 17888 | signed char b = p2;\n\ |
| 17889 | return a >> b;\n\ |
| 17890 | }"; |
| 17891 | |
| 17892 | signed char (*proc)(signed char a, signed char b); |
| 17893 | cod_parse_context context = new_cod_parse_context(); |
| 17894 | int dumped = 0; |
| 17895 | |
| 17896 | cod_code gen_code; |
| 17897 | |
| 17898 | /* test for signed char >> signed char */ |
| 17899 | if (verbose) printf("test for signed char >> signed char"); |
| 17900 | |
| 17901 | cod_assoc_externs(context, externs); |
| 17902 | cod_parse_for_context(extern_string, context); |
| 17903 | |
| 17904 | cod_subroutine_declaration("signed char proc(signed char p1, signed char p2)", |
| 17905 | context); |
| 17906 | gen_code = cod_code_gen(code, context); |
| 17907 | proc = (signed char (*)(signed char, signed char))(long)gen_code->func; |
| 17908 | |
| 17909 | |
| 17910 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 17911 | signed char source1_c = src1c_vals[i]; |
| 17912 | for (j=0 ; j < sizeof(sh_src2c_vals)/sizeof(sh_src2c_vals[0]) ; j++) { |
| 17913 | signed char source2_c = sh_src2c_vals[j]; |
| 17914 | |
| 17915 | signed char expected_result; |
| 17916 | signed char result; |
| 17917 | |
| 17918 | if (source2_c >= sizeof(source1_c)) goto skip64; |
| 17919 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 17920 | |
| 17921 | expected_result = (signed char) (source1_c >> source2_c); |
| 17922 | |
| 17923 | result = proc(source1_c, source2_c); |
| 17924 | if (expected_result != result) { |
| 17925 | printf("Failed signed char >> signed char test, expected %d, got %d, for %d >> %d\n", |
| 17926 | expected_result, result, source1_c, source2_c); |
| 17927 | if (dumped == 0) cod_dump(gen_code); |
| 17928 | failed++; |
| 17929 | dumped++; |
| 17930 | } |
| 17931 | skip64: ; |
| 17932 | } |
| 17933 | } |
| 17934 | if (verbose) printf(" done\n"); |
| 17935 | cod_free_parse_context(context); |
| 17936 | cod_code_free(gen_code); |
| 17937 | } |
| 17938 | if ((only_run_test == NULL((void*)0)) || |
| 17939 | (strcmp(only_run_test, "c>>uc") == 0)) { |
| 17940 | int i, j; |
| 17941 | static char code[] = "{\n\ |
| 17942 | signed char a = p1;\n\ |
| 17943 | unsigned char b = p2;\n\ |
| 17944 | return a >> b;\n\ |
| 17945 | }"; |
| 17946 | |
| 17947 | signed char (*proc)(signed char a, unsigned char b); |
| 17948 | cod_parse_context context = new_cod_parse_context(); |
| 17949 | int dumped = 0; |
| 17950 | |
| 17951 | cod_code gen_code; |
| 17952 | |
| 17953 | /* test for signed char >> unsigned char */ |
| 17954 | if (verbose) printf("test for signed char >> unsigned char"); |
| 17955 | |
| 17956 | cod_assoc_externs(context, externs); |
| 17957 | cod_parse_for_context(extern_string, context); |
| 17958 | |
| 17959 | cod_subroutine_declaration("signed char proc(signed char p1, unsigned char p2)", |
| 17960 | context); |
| 17961 | gen_code = cod_code_gen(code, context); |
| 17962 | proc = (signed char (*)(signed char, unsigned char))(long)gen_code->func; |
| 17963 | |
| 17964 | |
| 17965 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 17966 | signed char source1_c = src1c_vals[i]; |
| 17967 | for (j=0 ; j < sizeof(sh_src2c_vals)/sizeof(sh_src2c_vals[0]) ; j++) { |
| 17968 | unsigned char source2_uc = sh_src2c_vals[j]; |
| 17969 | |
| 17970 | signed char expected_result; |
| 17971 | signed char result; |
| 17972 | |
| 17973 | if (source2_uc >= sizeof(source1_c)) goto skip65; |
| 17974 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 17975 | |
| 17976 | expected_result = (signed char) (source1_c >> source2_uc); |
| 17977 | |
| 17978 | result = proc(source1_c, source2_uc); |
| 17979 | if (expected_result != result) { |
| 17980 | printf("Failed signed char >> unsigned char test, expected %d, got %d, for %d >> %u\n", |
| 17981 | expected_result, result, source1_c, source2_uc); |
| 17982 | if (dumped == 0) cod_dump(gen_code); |
| 17983 | failed++; |
| 17984 | dumped++; |
| 17985 | } |
| 17986 | skip65: ; |
| 17987 | } |
| 17988 | } |
| 17989 | if (verbose) printf(" done\n"); |
| 17990 | cod_free_parse_context(context); |
| 17991 | cod_code_free(gen_code); |
| 17992 | } |
| 17993 | if ((only_run_test == NULL((void*)0)) || |
| 17994 | (strcmp(only_run_test, "c>>s") == 0)) { |
| 17995 | int i, j; |
| 17996 | static char code[] = "{\n\ |
| 17997 | signed char a = p1;\n\ |
| 17998 | short b = p2;\n\ |
| 17999 | return a >> b;\n\ |
| 18000 | }"; |
| 18001 | |
| 18002 | signed char (*proc)(signed char a, short b); |
| 18003 | cod_parse_context context = new_cod_parse_context(); |
| 18004 | int dumped = 0; |
| 18005 | |
| 18006 | cod_code gen_code; |
| 18007 | |
| 18008 | /* test for signed char >> short */ |
| 18009 | if (verbose) printf("test for signed char >> short"); |
| 18010 | |
| 18011 | cod_assoc_externs(context, externs); |
| 18012 | cod_parse_for_context(extern_string, context); |
| 18013 | |
| 18014 | cod_subroutine_declaration("signed char proc(signed char p1, short p2)", |
| 18015 | context); |
| 18016 | gen_code = cod_code_gen(code, context); |
| 18017 | proc = (signed char (*)(signed char, short))(long)gen_code->func; |
| 18018 | |
| 18019 | |
| 18020 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 18021 | signed char source1_c = src1c_vals[i]; |
| 18022 | for (j=0 ; j < sizeof(sh_src2s_vals)/sizeof(sh_src2s_vals[0]) ; j++) { |
| 18023 | short source2_s = sh_src2s_vals[j]; |
| 18024 | |
| 18025 | signed char expected_result; |
| 18026 | signed char result; |
| 18027 | |
| 18028 | if (source2_s >= sizeof(source1_c)) goto skip66; |
| 18029 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 18030 | |
| 18031 | expected_result = (signed char) (source1_c >> source2_s); |
| 18032 | |
| 18033 | result = proc(source1_c, source2_s); |
| 18034 | if (expected_result != result) { |
| 18035 | printf("Failed signed char >> short test, expected %d, got %d, for %d >> %d\n", |
| 18036 | expected_result, result, source1_c, source2_s); |
| 18037 | if (dumped == 0) cod_dump(gen_code); |
| 18038 | failed++; |
| 18039 | dumped++; |
| 18040 | } |
| 18041 | skip66: ; |
| 18042 | } |
| 18043 | } |
| 18044 | if (verbose) printf(" done\n"); |
| 18045 | cod_free_parse_context(context); |
| 18046 | cod_code_free(gen_code); |
| 18047 | } |
| 18048 | if ((only_run_test == NULL((void*)0)) || |
| 18049 | (strcmp(only_run_test, "c>>us") == 0)) { |
| 18050 | int i, j; |
| 18051 | static char code[] = "{\n\ |
| 18052 | signed char a = p1;\n\ |
| 18053 | unsigned short b = p2;\n\ |
| 18054 | return a >> b;\n\ |
| 18055 | }"; |
| 18056 | |
| 18057 | signed char (*proc)(signed char a, unsigned short b); |
| 18058 | cod_parse_context context = new_cod_parse_context(); |
| 18059 | int dumped = 0; |
| 18060 | |
| 18061 | cod_code gen_code; |
| 18062 | |
| 18063 | /* test for signed char >> unsigned short */ |
| 18064 | if (verbose) printf("test for signed char >> unsigned short"); |
| 18065 | |
| 18066 | cod_assoc_externs(context, externs); |
| 18067 | cod_parse_for_context(extern_string, context); |
| 18068 | |
| 18069 | cod_subroutine_declaration("signed char proc(signed char p1, unsigned short p2)", |
| 18070 | context); |
| 18071 | gen_code = cod_code_gen(code, context); |
| 18072 | proc = (signed char (*)(signed char, unsigned short))(long)gen_code->func; |
| 18073 | |
| 18074 | |
| 18075 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 18076 | signed char source1_c = src1c_vals[i]; |
| 18077 | for (j=0 ; j < sizeof(sh_src2s_vals)/sizeof(sh_src2s_vals[0]) ; j++) { |
| 18078 | unsigned short source2_us = sh_src2s_vals[j]; |
| 18079 | |
| 18080 | signed char expected_result; |
| 18081 | signed char result; |
| 18082 | |
| 18083 | if (source2_us >= sizeof(source1_c)) goto skip67; |
| 18084 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 18085 | |
| 18086 | expected_result = (signed char) (source1_c >> source2_us); |
| 18087 | |
| 18088 | result = proc(source1_c, source2_us); |
| 18089 | if (expected_result != result) { |
| 18090 | printf("Failed signed char >> unsigned short test, expected %d, got %d, for %d >> %u\n", |
| 18091 | expected_result, result, source1_c, source2_us); |
| 18092 | if (dumped == 0) cod_dump(gen_code); |
| 18093 | failed++; |
| 18094 | dumped++; |
| 18095 | } |
| 18096 | skip67: ; |
| 18097 | } |
| 18098 | } |
| 18099 | if (verbose) printf(" done\n"); |
| 18100 | cod_free_parse_context(context); |
| 18101 | cod_code_free(gen_code); |
| 18102 | } |
| 18103 | if ((only_run_test == NULL((void*)0)) || |
| 18104 | (strcmp(only_run_test, "c>>i") == 0)) { |
| 18105 | int i, j; |
| 18106 | static char code[] = "{\n\ |
| 18107 | signed char a = p1;\n\ |
| 18108 | int b = p2;\n\ |
| 18109 | return a >> b;\n\ |
| 18110 | }"; |
| 18111 | |
| 18112 | signed char (*proc)(signed char a, int b); |
| 18113 | cod_parse_context context = new_cod_parse_context(); |
| 18114 | int dumped = 0; |
| 18115 | |
| 18116 | cod_code gen_code; |
| 18117 | |
| 18118 | /* test for signed char >> int */ |
| 18119 | if (verbose) printf("test for signed char >> int"); |
| 18120 | |
| 18121 | cod_assoc_externs(context, externs); |
| 18122 | cod_parse_for_context(extern_string, context); |
| 18123 | |
| 18124 | cod_subroutine_declaration("signed char proc(signed char p1, int p2)", |
| 18125 | context); |
| 18126 | gen_code = cod_code_gen(code, context); |
| 18127 | proc = (signed char (*)(signed char, int))(long)gen_code->func; |
| 18128 | |
| 18129 | |
| 18130 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 18131 | signed char source1_c = src1c_vals[i]; |
| 18132 | for (j=0 ; j < sizeof(sh_src2_vals)/sizeof(sh_src2_vals[0]) ; j++) { |
| 18133 | int source2_i = sh_src2_vals[j]; |
| 18134 | |
| 18135 | signed char expected_result; |
| 18136 | signed char result; |
| 18137 | |
| 18138 | if (source2_i >= sizeof(source1_c)) goto skip68; |
| 18139 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 18140 | |
| 18141 | expected_result = (signed char) (source1_c >> source2_i); |
| 18142 | |
| 18143 | result = proc(source1_c, source2_i); |
| 18144 | if (expected_result != result) { |
| 18145 | printf("Failed signed char >> int test, expected %d, got %d, for %d >> %d\n", |
| 18146 | expected_result, result, source1_c, source2_i); |
| 18147 | if (dumped == 0) cod_dump(gen_code); |
| 18148 | failed++; |
| 18149 | dumped++; |
| 18150 | } |
| 18151 | skip68: ; |
| 18152 | } |
| 18153 | } |
| 18154 | if (verbose) printf(" done\n"); |
| 18155 | cod_free_parse_context(context); |
| 18156 | cod_code_free(gen_code); |
| 18157 | } |
| 18158 | if ((only_run_test == NULL((void*)0)) || |
| 18159 | (strcmp(only_run_test, "c>>u") == 0)) { |
| 18160 | int i, j; |
| 18161 | static char code[] = "{\n\ |
| 18162 | signed char a = p1;\n\ |
| 18163 | unsigned int b = p2;\n\ |
| 18164 | return a >> b;\n\ |
| 18165 | }"; |
| 18166 | |
| 18167 | signed char (*proc)(signed char a, unsigned int b); |
| 18168 | cod_parse_context context = new_cod_parse_context(); |
| 18169 | int dumped = 0; |
| 18170 | |
| 18171 | cod_code gen_code; |
| 18172 | |
| 18173 | /* test for signed char >> unsigned int */ |
| 18174 | if (verbose) printf("test for signed char >> unsigned int"); |
| 18175 | |
| 18176 | cod_assoc_externs(context, externs); |
| 18177 | cod_parse_for_context(extern_string, context); |
| 18178 | |
| 18179 | cod_subroutine_declaration("signed char proc(signed char p1, unsigned int p2)", |
| 18180 | context); |
| 18181 | gen_code = cod_code_gen(code, context); |
| 18182 | proc = (signed char (*)(signed char, unsigned int))(long)gen_code->func; |
| 18183 | |
| 18184 | |
| 18185 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 18186 | signed char source1_c = src1c_vals[i]; |
| 18187 | for (j=0 ; j < sizeof(sh_src2_vals)/sizeof(sh_src2_vals[0]) ; j++) { |
| 18188 | unsigned int source2_u = sh_src2_vals[j]; |
| 18189 | |
| 18190 | signed char expected_result; |
| 18191 | signed char result; |
| 18192 | |
| 18193 | if (source2_u >= sizeof(source1_c)) goto skip69; |
| 18194 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 18195 | |
| 18196 | expected_result = (signed char) (source1_c >> source2_u); |
| 18197 | |
| 18198 | result = proc(source1_c, source2_u); |
| 18199 | if (expected_result != result) { |
| 18200 | printf("Failed signed char >> unsigned int test, expected %d, got %d, for %d >> %u\n", |
| 18201 | expected_result, result, source1_c, source2_u); |
| 18202 | if (dumped == 0) cod_dump(gen_code); |
| 18203 | failed++; |
| 18204 | dumped++; |
| 18205 | } |
| 18206 | skip69: ; |
| 18207 | } |
| 18208 | } |
| 18209 | if (verbose) printf(" done\n"); |
| 18210 | cod_free_parse_context(context); |
| 18211 | cod_code_free(gen_code); |
| 18212 | } |
| 18213 | if ((only_run_test == NULL((void*)0)) || |
| 18214 | (strcmp(only_run_test, "c>>ul") == 0)) { |
| 18215 | int i, j; |
| 18216 | static char code[] = "{\n\ |
| 18217 | signed char a = p1;\n\ |
| 18218 | unsigned long b = p2;\n\ |
| 18219 | return a >> b;\n\ |
| 18220 | }"; |
| 18221 | |
| 18222 | signed char (*proc)(signed char a, unsigned long b); |
| 18223 | cod_parse_context context = new_cod_parse_context(); |
| 18224 | int dumped = 0; |
| 18225 | |
| 18226 | cod_code gen_code; |
| 18227 | |
| 18228 | /* test for signed char >> unsigned long */ |
| 18229 | if (verbose) printf("test for signed char >> unsigned long"); |
| 18230 | |
| 18231 | cod_assoc_externs(context, externs); |
| 18232 | cod_parse_for_context(extern_string, context); |
| 18233 | |
| 18234 | cod_subroutine_declaration("signed char proc(signed char p1, unsigned long p2)", |
| 18235 | context); |
| 18236 | gen_code = cod_code_gen(code, context); |
| 18237 | proc = (signed char (*)(signed char, unsigned long))(long)gen_code->func; |
| 18238 | |
| 18239 | |
| 18240 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 18241 | signed char source1_c = src1c_vals[i]; |
| 18242 | for (j=0 ; j < sizeof(sh_src2_vals)/sizeof(sh_src2_vals[0]) ; j++) { |
| 18243 | unsigned long source2_ul = sh_src2_vals[j]; |
| 18244 | |
| 18245 | signed char expected_result; |
| 18246 | signed char result; |
| 18247 | |
| 18248 | if (source2_ul >= sizeof(source1_c)) goto skip70; |
| 18249 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 18250 | |
| 18251 | expected_result = (signed char) (source1_c >> source2_ul); |
| 18252 | |
| 18253 | result = proc(source1_c, source2_ul); |
| 18254 | if (expected_result != result) { |
| 18255 | printf("Failed signed char >> unsigned long test, expected %d, got %d, for %d >> %lu\n", |
| 18256 | expected_result, result, source1_c, source2_ul); |
| 18257 | if (dumped == 0) cod_dump(gen_code); |
| 18258 | failed++; |
| 18259 | dumped++; |
| 18260 | } |
| 18261 | skip70: ; |
| 18262 | } |
| 18263 | } |
| 18264 | if (verbose) printf(" done\n"); |
| 18265 | cod_free_parse_context(context); |
| 18266 | cod_code_free(gen_code); |
| 18267 | } |
| 18268 | if ((only_run_test == NULL((void*)0)) || |
| 18269 | (strcmp(only_run_test, "c>>l") == 0)) { |
| 18270 | int i, j; |
| 18271 | static char code[] = "{\n\ |
| 18272 | signed char a = p1;\n\ |
| 18273 | long b = p2;\n\ |
| 18274 | return a >> b;\n\ |
| 18275 | }"; |
| 18276 | |
| 18277 | signed char (*proc)(signed char a, long b); |
| 18278 | cod_parse_context context = new_cod_parse_context(); |
| 18279 | int dumped = 0; |
| 18280 | |
| 18281 | cod_code gen_code; |
| 18282 | |
| 18283 | /* test for signed char >> long */ |
| 18284 | if (verbose) printf("test for signed char >> long"); |
| 18285 | |
| 18286 | cod_assoc_externs(context, externs); |
| 18287 | cod_parse_for_context(extern_string, context); |
| 18288 | |
| 18289 | cod_subroutine_declaration("signed char proc(signed char p1, long p2)", |
| 18290 | context); |
| 18291 | gen_code = cod_code_gen(code, context); |
| 18292 | proc = (signed char (*)(signed char, long))(long)gen_code->func; |
| 18293 | |
| 18294 | |
| 18295 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 18296 | signed char source1_c = src1c_vals[i]; |
| 18297 | for (j=0 ; j < sizeof(sh_src2_vals)/sizeof(sh_src2_vals[0]) ; j++) { |
| 18298 | long source2_l = sh_src2_vals[j]; |
| 18299 | |
| 18300 | signed char expected_result; |
| 18301 | signed char result; |
| 18302 | |
| 18303 | if (source2_l >= sizeof(source1_c)) goto skip71; |
| 18304 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 18305 | |
| 18306 | expected_result = (signed char) (source1_c >> source2_l); |
| 18307 | |
| 18308 | result = proc(source1_c, source2_l); |
| 18309 | if (expected_result != result) { |
| 18310 | printf("Failed signed char >> long test, expected %d, got %d, for %d >> %ld\n", |
| 18311 | expected_result, result, source1_c, source2_l); |
| 18312 | if (dumped == 0) cod_dump(gen_code); |
| 18313 | failed++; |
| 18314 | dumped++; |
| 18315 | } |
| 18316 | skip71: ; |
| 18317 | } |
| 18318 | } |
| 18319 | if (verbose) printf(" done\n"); |
| 18320 | cod_free_parse_context(context); |
| 18321 | cod_code_free(gen_code); |
| 18322 | } |
| 18323 | } |
| 18324 | void rsh_uc_tests() |
| 18325 | { |
| 18326 | if ((only_run_test == NULL((void*)0)) || |
| 18327 | (strcmp(only_run_test, "uc>>c") == 0)) { |
| 18328 | int i, j; |
| 18329 | static char code[] = "{\n\ |
| 18330 | unsigned char a = p1;\n\ |
| 18331 | signed char b = p2;\n\ |
| 18332 | return a >> b;\n\ |
| 18333 | }"; |
| 18334 | |
| 18335 | unsigned char (*proc)(unsigned char a, signed char b); |
| 18336 | cod_parse_context context = new_cod_parse_context(); |
| 18337 | int dumped = 0; |
| 18338 | |
| 18339 | cod_code gen_code; |
| 18340 | |
| 18341 | /* test for unsigned char >> signed char */ |
| 18342 | if (verbose) printf("test for unsigned char >> signed char"); |
| 18343 | |
| 18344 | cod_assoc_externs(context, externs); |
| 18345 | cod_parse_for_context(extern_string, context); |
| 18346 | |
| 18347 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, signed char p2)", |
| 18348 | context); |
| 18349 | gen_code = cod_code_gen(code, context); |
| 18350 | proc = (unsigned char (*)(unsigned char, signed char))(long)gen_code->func; |
| 18351 | |
| 18352 | |
| 18353 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 18354 | unsigned char source1_uc = src1uc_vals[i]; |
| 18355 | for (j=0 ; j < sizeof(sh_src2c_vals)/sizeof(sh_src2c_vals[0]) ; j++) { |
| 18356 | signed char source2_c = sh_src2c_vals[j]; |
| 18357 | |
| 18358 | unsigned char expected_result; |
| 18359 | unsigned char result; |
| 18360 | |
| 18361 | if (source2_c >= sizeof(source1_uc)) goto skip72; |
| 18362 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 18363 | |
| 18364 | expected_result = (unsigned char) (source1_uc >> source2_c); |
| 18365 | |
| 18366 | result = proc(source1_uc, source2_c); |
| 18367 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 18368 | if (expected_result != result) { |
| 18369 | printf("Failed unsigned char >> signed char test, expected %u, got %u, for %u >> %d\n", |
| 18370 | expected_result, result, source1_uc, source2_c); |
| 18371 | if (dumped == 0) cod_dump(gen_code); |
| 18372 | failed++; |
| 18373 | dumped++; |
| 18374 | } |
| 18375 | skip72: ; |
| 18376 | } |
| 18377 | } |
| 18378 | if (verbose) printf(" done\n"); |
| 18379 | cod_free_parse_context(context); |
| 18380 | cod_code_free(gen_code); |
| 18381 | } |
| 18382 | if ((only_run_test == NULL((void*)0)) || |
| 18383 | (strcmp(only_run_test, "uc>>uc") == 0)) { |
| 18384 | int i, j; |
| 18385 | static char code[] = "{\n\ |
| 18386 | unsigned char a = p1;\n\ |
| 18387 | unsigned char b = p2;\n\ |
| 18388 | return a >> b;\n\ |
| 18389 | }"; |
| 18390 | |
| 18391 | unsigned char (*proc)(unsigned char a, unsigned char b); |
| 18392 | cod_parse_context context = new_cod_parse_context(); |
| 18393 | int dumped = 0; |
| 18394 | |
| 18395 | cod_code gen_code; |
| 18396 | |
| 18397 | /* test for unsigned char >> unsigned char */ |
| 18398 | if (verbose) printf("test for unsigned char >> unsigned char"); |
| 18399 | |
| 18400 | cod_assoc_externs(context, externs); |
| 18401 | cod_parse_for_context(extern_string, context); |
| 18402 | |
| 18403 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, unsigned char p2)", |
| 18404 | context); |
| 18405 | gen_code = cod_code_gen(code, context); |
| 18406 | proc = (unsigned char (*)(unsigned char, unsigned char))(long)gen_code->func; |
| 18407 | |
| 18408 | |
| 18409 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 18410 | unsigned char source1_uc = src1uc_vals[i]; |
| 18411 | for (j=0 ; j < sizeof(sh_src2c_vals)/sizeof(sh_src2c_vals[0]) ; j++) { |
| 18412 | unsigned char source2_uc = sh_src2c_vals[j]; |
| 18413 | |
| 18414 | unsigned char expected_result; |
| 18415 | unsigned char result; |
| 18416 | |
| 18417 | if (source2_uc >= sizeof(source1_uc)) goto skip73; |
| 18418 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 18419 | |
| 18420 | expected_result = (unsigned char) (source1_uc >> source2_uc); |
| 18421 | |
| 18422 | result = proc(source1_uc, source2_uc); |
| 18423 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 18424 | if (expected_result != result) { |
| 18425 | printf("Failed unsigned char >> unsigned char test, expected %u, got %u, for %u >> %u\n", |
| 18426 | expected_result, result, source1_uc, source2_uc); |
| 18427 | if (dumped == 0) cod_dump(gen_code); |
| 18428 | failed++; |
| 18429 | dumped++; |
| 18430 | } |
| 18431 | skip73: ; |
| 18432 | } |
| 18433 | } |
| 18434 | if (verbose) printf(" done\n"); |
| 18435 | cod_free_parse_context(context); |
| 18436 | cod_code_free(gen_code); |
| 18437 | } |
| 18438 | if ((only_run_test == NULL((void*)0)) || |
| 18439 | (strcmp(only_run_test, "uc>>s") == 0)) { |
| 18440 | int i, j; |
| 18441 | static char code[] = "{\n\ |
| 18442 | unsigned char a = p1;\n\ |
| 18443 | short b = p2;\n\ |
| 18444 | return a >> b;\n\ |
| 18445 | }"; |
| 18446 | |
| 18447 | unsigned char (*proc)(unsigned char a, short b); |
| 18448 | cod_parse_context context = new_cod_parse_context(); |
| 18449 | int dumped = 0; |
| 18450 | |
| 18451 | cod_code gen_code; |
| 18452 | |
| 18453 | /* test for unsigned char >> short */ |
| 18454 | if (verbose) printf("test for unsigned char >> short"); |
| 18455 | |
| 18456 | cod_assoc_externs(context, externs); |
| 18457 | cod_parse_for_context(extern_string, context); |
| 18458 | |
| 18459 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, short p2)", |
| 18460 | context); |
| 18461 | gen_code = cod_code_gen(code, context); |
| 18462 | proc = (unsigned char (*)(unsigned char, short))(long)gen_code->func; |
| 18463 | |
| 18464 | |
| 18465 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 18466 | unsigned char source1_uc = src1uc_vals[i]; |
| 18467 | for (j=0 ; j < sizeof(sh_src2s_vals)/sizeof(sh_src2s_vals[0]) ; j++) { |
| 18468 | short source2_s = sh_src2s_vals[j]; |
| 18469 | |
| 18470 | unsigned char expected_result; |
| 18471 | unsigned char result; |
| 18472 | |
| 18473 | if (source2_s >= sizeof(source1_uc)) goto skip74; |
| 18474 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 18475 | |
| 18476 | expected_result = (unsigned char) (source1_uc >> source2_s); |
| 18477 | |
| 18478 | result = proc(source1_uc, source2_s); |
| 18479 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 18480 | if (expected_result != result) { |
| 18481 | printf("Failed unsigned char >> short test, expected %u, got %u, for %u >> %d\n", |
| 18482 | expected_result, result, source1_uc, source2_s); |
| 18483 | if (dumped == 0) cod_dump(gen_code); |
| 18484 | failed++; |
| 18485 | dumped++; |
| 18486 | } |
| 18487 | skip74: ; |
| 18488 | } |
| 18489 | } |
| 18490 | if (verbose) printf(" done\n"); |
| 18491 | cod_free_parse_context(context); |
| 18492 | cod_code_free(gen_code); |
| 18493 | } |
| 18494 | if ((only_run_test == NULL((void*)0)) || |
| 18495 | (strcmp(only_run_test, "uc>>us") == 0)) { |
| 18496 | int i, j; |
| 18497 | static char code[] = "{\n\ |
| 18498 | unsigned char a = p1;\n\ |
| 18499 | unsigned short b = p2;\n\ |
| 18500 | return a >> b;\n\ |
| 18501 | }"; |
| 18502 | |
| 18503 | unsigned char (*proc)(unsigned char a, unsigned short b); |
| 18504 | cod_parse_context context = new_cod_parse_context(); |
| 18505 | int dumped = 0; |
| 18506 | |
| 18507 | cod_code gen_code; |
| 18508 | |
| 18509 | /* test for unsigned char >> unsigned short */ |
| 18510 | if (verbose) printf("test for unsigned char >> unsigned short"); |
| 18511 | |
| 18512 | cod_assoc_externs(context, externs); |
| 18513 | cod_parse_for_context(extern_string, context); |
| 18514 | |
| 18515 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, unsigned short p2)", |
| 18516 | context); |
| 18517 | gen_code = cod_code_gen(code, context); |
| 18518 | proc = (unsigned char (*)(unsigned char, unsigned short))(long)gen_code->func; |
| 18519 | |
| 18520 | |
| 18521 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 18522 | unsigned char source1_uc = src1uc_vals[i]; |
| 18523 | for (j=0 ; j < sizeof(sh_src2s_vals)/sizeof(sh_src2s_vals[0]) ; j++) { |
| 18524 | unsigned short source2_us = sh_src2s_vals[j]; |
| 18525 | |
| 18526 | unsigned char expected_result; |
| 18527 | unsigned char result; |
| 18528 | |
| 18529 | if (source2_us >= sizeof(source1_uc)) goto skip75; |
| 18530 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 18531 | |
| 18532 | expected_result = (unsigned char) (source1_uc >> source2_us); |
| 18533 | |
| 18534 | result = proc(source1_uc, source2_us); |
| 18535 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 18536 | if (expected_result != result) { |
| 18537 | printf("Failed unsigned char >> unsigned short test, expected %u, got %u, for %u >> %u\n", |
| 18538 | expected_result, result, source1_uc, source2_us); |
| 18539 | if (dumped == 0) cod_dump(gen_code); |
| 18540 | failed++; |
| 18541 | dumped++; |
| 18542 | } |
| 18543 | skip75: ; |
| 18544 | } |
| 18545 | } |
| 18546 | if (verbose) printf(" done\n"); |
| 18547 | cod_free_parse_context(context); |
| 18548 | cod_code_free(gen_code); |
| 18549 | } |
| 18550 | if ((only_run_test == NULL((void*)0)) || |
| 18551 | (strcmp(only_run_test, "uc>>i") == 0)) { |
| 18552 | int i, j; |
| 18553 | static char code[] = "{\n\ |
| 18554 | unsigned char a = p1;\n\ |
| 18555 | int b = p2;\n\ |
| 18556 | return a >> b;\n\ |
| 18557 | }"; |
| 18558 | |
| 18559 | unsigned char (*proc)(unsigned char a, int b); |
| 18560 | cod_parse_context context = new_cod_parse_context(); |
| 18561 | int dumped = 0; |
| 18562 | |
| 18563 | cod_code gen_code; |
| 18564 | |
| 18565 | /* test for unsigned char >> int */ |
| 18566 | if (verbose) printf("test for unsigned char >> int"); |
| 18567 | |
| 18568 | cod_assoc_externs(context, externs); |
| 18569 | cod_parse_for_context(extern_string, context); |
| 18570 | |
| 18571 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, int p2)", |
| 18572 | context); |
| 18573 | gen_code = cod_code_gen(code, context); |
| 18574 | proc = (unsigned char (*)(unsigned char, int))(long)gen_code->func; |
| 18575 | |
| 18576 | |
| 18577 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 18578 | unsigned char source1_uc = src1uc_vals[i]; |
| 18579 | for (j=0 ; j < sizeof(sh_src2_vals)/sizeof(sh_src2_vals[0]) ; j++) { |
| 18580 | int source2_i = sh_src2_vals[j]; |
| 18581 | |
| 18582 | unsigned char expected_result; |
| 18583 | unsigned char result; |
| 18584 | |
| 18585 | if (source2_i >= sizeof(source1_uc)) goto skip76; |
| 18586 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 18587 | |
| 18588 | expected_result = (unsigned char) (source1_uc >> source2_i); |
| 18589 | |
| 18590 | result = proc(source1_uc, source2_i); |
| 18591 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 18592 | if (expected_result != result) { |
| 18593 | printf("Failed unsigned char >> int test, expected %u, got %u, for %u >> %d\n", |
| 18594 | expected_result, result, source1_uc, source2_i); |
| 18595 | if (dumped == 0) cod_dump(gen_code); |
| 18596 | failed++; |
| 18597 | dumped++; |
| 18598 | } |
| 18599 | skip76: ; |
| 18600 | } |
| 18601 | } |
| 18602 | if (verbose) printf(" done\n"); |
| 18603 | cod_free_parse_context(context); |
| 18604 | cod_code_free(gen_code); |
| 18605 | } |
| 18606 | if ((only_run_test == NULL((void*)0)) || |
| 18607 | (strcmp(only_run_test, "uc>>u") == 0)) { |
| 18608 | int i, j; |
| 18609 | static char code[] = "{\n\ |
| 18610 | unsigned char a = p1;\n\ |
| 18611 | unsigned int b = p2;\n\ |
| 18612 | return a >> b;\n\ |
| 18613 | }"; |
| 18614 | |
| 18615 | unsigned char (*proc)(unsigned char a, unsigned int b); |
| 18616 | cod_parse_context context = new_cod_parse_context(); |
| 18617 | int dumped = 0; |
| 18618 | |
| 18619 | cod_code gen_code; |
| 18620 | |
| 18621 | /* test for unsigned char >> unsigned int */ |
| 18622 | if (verbose) printf("test for unsigned char >> unsigned int"); |
| 18623 | |
| 18624 | cod_assoc_externs(context, externs); |
| 18625 | cod_parse_for_context(extern_string, context); |
| 18626 | |
| 18627 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, unsigned int p2)", |
| 18628 | context); |
| 18629 | gen_code = cod_code_gen(code, context); |
| 18630 | proc = (unsigned char (*)(unsigned char, unsigned int))(long)gen_code->func; |
| 18631 | |
| 18632 | |
| 18633 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 18634 | unsigned char source1_uc = src1uc_vals[i]; |
| 18635 | for (j=0 ; j < sizeof(sh_src2_vals)/sizeof(sh_src2_vals[0]) ; j++) { |
| 18636 | unsigned int source2_u = sh_src2_vals[j]; |
| 18637 | |
| 18638 | unsigned char expected_result; |
| 18639 | unsigned char result; |
| 18640 | |
| 18641 | if (source2_u >= sizeof(source1_uc)) goto skip77; |
| 18642 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 18643 | |
| 18644 | expected_result = (unsigned char) (source1_uc >> source2_u); |
| 18645 | |
| 18646 | result = proc(source1_uc, source2_u); |
| 18647 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 18648 | if (expected_result != result) { |
| 18649 | printf("Failed unsigned char >> unsigned int test, expected %u, got %u, for %u >> %u\n", |
| 18650 | expected_result, result, source1_uc, source2_u); |
| 18651 | if (dumped == 0) cod_dump(gen_code); |
| 18652 | failed++; |
| 18653 | dumped++; |
| 18654 | } |
| 18655 | skip77: ; |
| 18656 | } |
| 18657 | } |
| 18658 | if (verbose) printf(" done\n"); |
| 18659 | cod_free_parse_context(context); |
| 18660 | cod_code_free(gen_code); |
| 18661 | } |
| 18662 | if ((only_run_test == NULL((void*)0)) || |
| 18663 | (strcmp(only_run_test, "uc>>ul") == 0)) { |
| 18664 | int i, j; |
| 18665 | static char code[] = "{\n\ |
| 18666 | unsigned char a = p1;\n\ |
| 18667 | unsigned long b = p2;\n\ |
| 18668 | return a >> b;\n\ |
| 18669 | }"; |
| 18670 | |
| 18671 | unsigned char (*proc)(unsigned char a, unsigned long b); |
| 18672 | cod_parse_context context = new_cod_parse_context(); |
| 18673 | int dumped = 0; |
| 18674 | |
| 18675 | cod_code gen_code; |
| 18676 | |
| 18677 | /* test for unsigned char >> unsigned long */ |
| 18678 | if (verbose) printf("test for unsigned char >> unsigned long"); |
| 18679 | |
| 18680 | cod_assoc_externs(context, externs); |
| 18681 | cod_parse_for_context(extern_string, context); |
| 18682 | |
| 18683 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, unsigned long p2)", |
| 18684 | context); |
| 18685 | gen_code = cod_code_gen(code, context); |
| 18686 | proc = (unsigned char (*)(unsigned char, unsigned long))(long)gen_code->func; |
| 18687 | |
| 18688 | |
| 18689 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 18690 | unsigned char source1_uc = src1uc_vals[i]; |
| 18691 | for (j=0 ; j < sizeof(sh_src2_vals)/sizeof(sh_src2_vals[0]) ; j++) { |
| 18692 | unsigned long source2_ul = sh_src2_vals[j]; |
| 18693 | |
| 18694 | unsigned char expected_result; |
| 18695 | unsigned char result; |
| 18696 | |
| 18697 | if (source2_ul >= sizeof(source1_uc)) goto skip78; |
| 18698 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 18699 | |
| 18700 | expected_result = (unsigned char) (source1_uc >> source2_ul); |
| 18701 | |
| 18702 | result = proc(source1_uc, source2_ul); |
| 18703 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 18704 | if (expected_result != result) { |
| 18705 | printf("Failed unsigned char >> unsigned long test, expected %u, got %u, for %u >> %lu\n", |
| 18706 | expected_result, result, source1_uc, source2_ul); |
| 18707 | if (dumped == 0) cod_dump(gen_code); |
| 18708 | failed++; |
| 18709 | dumped++; |
| 18710 | } |
| 18711 | skip78: ; |
| 18712 | } |
| 18713 | } |
| 18714 | if (verbose) printf(" done\n"); |
| 18715 | cod_free_parse_context(context); |
| 18716 | cod_code_free(gen_code); |
| 18717 | } |
| 18718 | if ((only_run_test == NULL((void*)0)) || |
| 18719 | (strcmp(only_run_test, "uc>>l") == 0)) { |
| 18720 | int i, j; |
| 18721 | static char code[] = "{\n\ |
| 18722 | unsigned char a = p1;\n\ |
| 18723 | long b = p2;\n\ |
| 18724 | return a >> b;\n\ |
| 18725 | }"; |
| 18726 | |
| 18727 | unsigned char (*proc)(unsigned char a, long b); |
| 18728 | cod_parse_context context = new_cod_parse_context(); |
| 18729 | int dumped = 0; |
| 18730 | |
| 18731 | cod_code gen_code; |
| 18732 | |
| 18733 | /* test for unsigned char >> long */ |
| 18734 | if (verbose) printf("test for unsigned char >> long"); |
| 18735 | |
| 18736 | cod_assoc_externs(context, externs); |
| 18737 | cod_parse_for_context(extern_string, context); |
| 18738 | |
| 18739 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, long p2)", |
| 18740 | context); |
| 18741 | gen_code = cod_code_gen(code, context); |
| 18742 | proc = (unsigned char (*)(unsigned char, long))(long)gen_code->func; |
| 18743 | |
| 18744 | |
| 18745 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 18746 | unsigned char source1_uc = src1uc_vals[i]; |
| 18747 | for (j=0 ; j < sizeof(sh_src2_vals)/sizeof(sh_src2_vals[0]) ; j++) { |
| 18748 | long source2_l = sh_src2_vals[j]; |
| 18749 | |
| 18750 | unsigned char expected_result; |
| 18751 | unsigned char result; |
| 18752 | |
| 18753 | if (source2_l >= sizeof(source1_uc)) goto skip79; |
| 18754 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 18755 | |
| 18756 | expected_result = (unsigned char) (source1_uc >> source2_l); |
| 18757 | |
| 18758 | result = proc(source1_uc, source2_l); |
| 18759 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 18760 | if (expected_result != result) { |
| 18761 | printf("Failed unsigned char >> long test, expected %u, got %u, for %u >> %ld\n", |
| 18762 | expected_result, result, source1_uc, source2_l); |
| 18763 | if (dumped == 0) cod_dump(gen_code); |
| 18764 | failed++; |
| 18765 | dumped++; |
| 18766 | } |
| 18767 | skip79: ; |
| 18768 | } |
| 18769 | } |
| 18770 | if (verbose) printf(" done\n"); |
| 18771 | cod_free_parse_context(context); |
| 18772 | cod_code_free(gen_code); |
| 18773 | } |
| 18774 | } |
| 18775 | void rsh_s_tests() |
| 18776 | { |
| 18777 | if ((only_run_test == NULL((void*)0)) || |
| 18778 | (strcmp(only_run_test, "s>>c") == 0)) { |
| 18779 | int i, j; |
| 18780 | static char code[] = "{\n\ |
| 18781 | short a = p1;\n\ |
| 18782 | signed char b = p2;\n\ |
| 18783 | return a >> b;\n\ |
| 18784 | }"; |
| 18785 | |
| 18786 | short (*proc)(short a, signed char b); |
| 18787 | cod_parse_context context = new_cod_parse_context(); |
| 18788 | int dumped = 0; |
| 18789 | |
| 18790 | cod_code gen_code; |
| 18791 | |
| 18792 | /* test for short >> signed char */ |
| 18793 | if (verbose) printf("test for short >> signed char"); |
| 18794 | |
| 18795 | cod_assoc_externs(context, externs); |
| 18796 | cod_parse_for_context(extern_string, context); |
| 18797 | |
| 18798 | cod_subroutine_declaration("short proc(short p1, signed char p2)", |
| 18799 | context); |
| 18800 | gen_code = cod_code_gen(code, context); |
| 18801 | proc = (short (*)(short, signed char))(long)gen_code->func; |
| 18802 | |
| 18803 | |
| 18804 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 18805 | short source1_s = src1s_vals[i]; |
| 18806 | for (j=0 ; j < sizeof(sh_src2c_vals)/sizeof(sh_src2c_vals[0]) ; j++) { |
| 18807 | signed char source2_c = sh_src2c_vals[j]; |
| 18808 | |
| 18809 | short expected_result; |
| 18810 | short result; |
| 18811 | |
| 18812 | if (source2_c >= sizeof(source1_s)) goto skip80; |
| 18813 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 18814 | |
| 18815 | expected_result = (short) (source1_s >> source2_c); |
| 18816 | |
| 18817 | result = proc(source1_s, source2_c); |
| 18818 | if (expected_result != result) { |
| 18819 | printf("Failed short >> signed char test, expected %d, got %d, for %d >> %d\n", |
| 18820 | expected_result, result, source1_s, source2_c); |
| 18821 | if (dumped == 0) cod_dump(gen_code); |
| 18822 | failed++; |
| 18823 | dumped++; |
| 18824 | } |
| 18825 | skip80: ; |
| 18826 | } |
| 18827 | } |
| 18828 | if (verbose) printf(" done\n"); |
| 18829 | cod_free_parse_context(context); |
| 18830 | cod_code_free(gen_code); |
| 18831 | } |
| 18832 | if ((only_run_test == NULL((void*)0)) || |
| 18833 | (strcmp(only_run_test, "s>>uc") == 0)) { |
| 18834 | int i, j; |
| 18835 | static char code[] = "{\n\ |
| 18836 | short a = p1;\n\ |
| 18837 | unsigned char b = p2;\n\ |
| 18838 | return a >> b;\n\ |
| 18839 | }"; |
| 18840 | |
| 18841 | short (*proc)(short a, unsigned char b); |
| 18842 | cod_parse_context context = new_cod_parse_context(); |
| 18843 | int dumped = 0; |
| 18844 | |
| 18845 | cod_code gen_code; |
| 18846 | |
| 18847 | /* test for short >> unsigned char */ |
| 18848 | if (verbose) printf("test for short >> unsigned char"); |
| 18849 | |
| 18850 | cod_assoc_externs(context, externs); |
| 18851 | cod_parse_for_context(extern_string, context); |
| 18852 | |
| 18853 | cod_subroutine_declaration("short proc(short p1, unsigned char p2)", |
| 18854 | context); |
| 18855 | gen_code = cod_code_gen(code, context); |
| 18856 | proc = (short (*)(short, unsigned char))(long)gen_code->func; |
| 18857 | |
| 18858 | |
| 18859 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 18860 | short source1_s = src1s_vals[i]; |
| 18861 | for (j=0 ; j < sizeof(sh_src2c_vals)/sizeof(sh_src2c_vals[0]) ; j++) { |
| 18862 | unsigned char source2_uc = sh_src2c_vals[j]; |
| 18863 | |
| 18864 | short expected_result; |
| 18865 | short result; |
| 18866 | |
| 18867 | if (source2_uc >= sizeof(source1_s)) goto skip81; |
| 18868 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 18869 | |
| 18870 | expected_result = (short) (source1_s >> source2_uc); |
| 18871 | |
| 18872 | result = proc(source1_s, source2_uc); |
| 18873 | if (expected_result != result) { |
| 18874 | printf("Failed short >> unsigned char test, expected %d, got %d, for %d >> %u\n", |
| 18875 | expected_result, result, source1_s, source2_uc); |
| 18876 | if (dumped == 0) cod_dump(gen_code); |
| 18877 | failed++; |
| 18878 | dumped++; |
| 18879 | } |
| 18880 | skip81: ; |
| 18881 | } |
| 18882 | } |
| 18883 | if (verbose) printf(" done\n"); |
| 18884 | cod_free_parse_context(context); |
| 18885 | cod_code_free(gen_code); |
| 18886 | } |
| 18887 | if ((only_run_test == NULL((void*)0)) || |
| 18888 | (strcmp(only_run_test, "s>>s") == 0)) { |
| 18889 | int i, j; |
| 18890 | static char code[] = "{\n\ |
| 18891 | short a = p1;\n\ |
| 18892 | short b = p2;\n\ |
| 18893 | return a >> b;\n\ |
| 18894 | }"; |
| 18895 | |
| 18896 | short (*proc)(short a, short b); |
| 18897 | cod_parse_context context = new_cod_parse_context(); |
| 18898 | int dumped = 0; |
| 18899 | |
| 18900 | cod_code gen_code; |
| 18901 | |
| 18902 | /* test for short >> short */ |
| 18903 | if (verbose) printf("test for short >> short"); |
| 18904 | |
| 18905 | cod_assoc_externs(context, externs); |
| 18906 | cod_parse_for_context(extern_string, context); |
| 18907 | |
| 18908 | cod_subroutine_declaration("short proc(short p1, short p2)", |
| 18909 | context); |
| 18910 | gen_code = cod_code_gen(code, context); |
| 18911 | proc = (short (*)(short, short))(long)gen_code->func; |
| 18912 | |
| 18913 | |
| 18914 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 18915 | short source1_s = src1s_vals[i]; |
| 18916 | for (j=0 ; j < sizeof(sh_src2s_vals)/sizeof(sh_src2s_vals[0]) ; j++) { |
| 18917 | short source2_s = sh_src2s_vals[j]; |
| 18918 | |
| 18919 | short expected_result; |
| 18920 | short result; |
| 18921 | |
| 18922 | if (source2_s >= sizeof(source1_s)) goto skip82; |
| 18923 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 18924 | |
| 18925 | expected_result = (short) (source1_s >> source2_s); |
| 18926 | |
| 18927 | result = proc(source1_s, source2_s); |
| 18928 | if (expected_result != result) { |
| 18929 | printf("Failed short >> short test, expected %d, got %d, for %d >> %d\n", |
| 18930 | expected_result, result, source1_s, source2_s); |
| 18931 | if (dumped == 0) cod_dump(gen_code); |
| 18932 | failed++; |
| 18933 | dumped++; |
| 18934 | } |
| 18935 | skip82: ; |
| 18936 | } |
| 18937 | } |
| 18938 | if (verbose) printf(" done\n"); |
| 18939 | cod_free_parse_context(context); |
| 18940 | cod_code_free(gen_code); |
| 18941 | } |
| 18942 | if ((only_run_test == NULL((void*)0)) || |
| 18943 | (strcmp(only_run_test, "s>>us") == 0)) { |
| 18944 | int i, j; |
| 18945 | static char code[] = "{\n\ |
| 18946 | short a = p1;\n\ |
| 18947 | unsigned short b = p2;\n\ |
| 18948 | return a >> b;\n\ |
| 18949 | }"; |
| 18950 | |
| 18951 | short (*proc)(short a, unsigned short b); |
| 18952 | cod_parse_context context = new_cod_parse_context(); |
| 18953 | int dumped = 0; |
| 18954 | |
| 18955 | cod_code gen_code; |
| 18956 | |
| 18957 | /* test for short >> unsigned short */ |
| 18958 | if (verbose) printf("test for short >> unsigned short"); |
| 18959 | |
| 18960 | cod_assoc_externs(context, externs); |
| 18961 | cod_parse_for_context(extern_string, context); |
| 18962 | |
| 18963 | cod_subroutine_declaration("short proc(short p1, unsigned short p2)", |
| 18964 | context); |
| 18965 | gen_code = cod_code_gen(code, context); |
| 18966 | proc = (short (*)(short, unsigned short))(long)gen_code->func; |
| 18967 | |
| 18968 | |
| 18969 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 18970 | short source1_s = src1s_vals[i]; |
| 18971 | for (j=0 ; j < sizeof(sh_src2s_vals)/sizeof(sh_src2s_vals[0]) ; j++) { |
| 18972 | unsigned short source2_us = sh_src2s_vals[j]; |
| 18973 | |
| 18974 | short expected_result; |
| 18975 | short result; |
| 18976 | |
| 18977 | if (source2_us >= sizeof(source1_s)) goto skip83; |
| 18978 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 18979 | |
| 18980 | expected_result = (short) (source1_s >> source2_us); |
| 18981 | |
| 18982 | result = proc(source1_s, source2_us); |
| 18983 | if (expected_result != result) { |
| 18984 | printf("Failed short >> unsigned short test, expected %d, got %d, for %d >> %u\n", |
| 18985 | expected_result, result, source1_s, source2_us); |
| 18986 | if (dumped == 0) cod_dump(gen_code); |
| 18987 | failed++; |
| 18988 | dumped++; |
| 18989 | } |
| 18990 | skip83: ; |
| 18991 | } |
| 18992 | } |
| 18993 | if (verbose) printf(" done\n"); |
| 18994 | cod_free_parse_context(context); |
| 18995 | cod_code_free(gen_code); |
| 18996 | } |
| 18997 | if ((only_run_test == NULL((void*)0)) || |
| 18998 | (strcmp(only_run_test, "s>>i") == 0)) { |
| 18999 | int i, j; |
| 19000 | static char code[] = "{\n\ |
| 19001 | short a = p1;\n\ |
| 19002 | int b = p2;\n\ |
| 19003 | return a >> b;\n\ |
| 19004 | }"; |
| 19005 | |
| 19006 | short (*proc)(short a, int b); |
| 19007 | cod_parse_context context = new_cod_parse_context(); |
| 19008 | int dumped = 0; |
| 19009 | |
| 19010 | cod_code gen_code; |
| 19011 | |
| 19012 | /* test for short >> int */ |
| 19013 | if (verbose) printf("test for short >> int"); |
| 19014 | |
| 19015 | cod_assoc_externs(context, externs); |
| 19016 | cod_parse_for_context(extern_string, context); |
| 19017 | |
| 19018 | cod_subroutine_declaration("short proc(short p1, int p2)", |
| 19019 | context); |
| 19020 | gen_code = cod_code_gen(code, context); |
| 19021 | proc = (short (*)(short, int))(long)gen_code->func; |
| 19022 | |
| 19023 | |
| 19024 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 19025 | short source1_s = src1s_vals[i]; |
| 19026 | for (j=0 ; j < sizeof(sh_src2_vals)/sizeof(sh_src2_vals[0]) ; j++) { |
| 19027 | int source2_i = sh_src2_vals[j]; |
| 19028 | |
| 19029 | short expected_result; |
| 19030 | short result; |
| 19031 | |
| 19032 | if (source2_i >= sizeof(source1_s)) goto skip84; |
| 19033 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 19034 | |
| 19035 | expected_result = (short) (source1_s >> source2_i); |
| 19036 | |
| 19037 | result = proc(source1_s, source2_i); |
| 19038 | if (expected_result != result) { |
| 19039 | printf("Failed short >> int test, expected %d, got %d, for %d >> %d\n", |
| 19040 | expected_result, result, source1_s, source2_i); |
| 19041 | if (dumped == 0) cod_dump(gen_code); |
| 19042 | failed++; |
| 19043 | dumped++; |
| 19044 | } |
| 19045 | skip84: ; |
| 19046 | } |
| 19047 | } |
| 19048 | if (verbose) printf(" done\n"); |
| 19049 | cod_free_parse_context(context); |
| 19050 | cod_code_free(gen_code); |
| 19051 | } |
| 19052 | if ((only_run_test == NULL((void*)0)) || |
| 19053 | (strcmp(only_run_test, "s>>u") == 0)) { |
| 19054 | int i, j; |
| 19055 | static char code[] = "{\n\ |
| 19056 | short a = p1;\n\ |
| 19057 | unsigned int b = p2;\n\ |
| 19058 | return a >> b;\n\ |
| 19059 | }"; |
| 19060 | |
| 19061 | short (*proc)(short a, unsigned int b); |
| 19062 | cod_parse_context context = new_cod_parse_context(); |
| 19063 | int dumped = 0; |
| 19064 | |
| 19065 | cod_code gen_code; |
| 19066 | |
| 19067 | /* test for short >> unsigned int */ |
| 19068 | if (verbose) printf("test for short >> unsigned int"); |
| 19069 | |
| 19070 | cod_assoc_externs(context, externs); |
| 19071 | cod_parse_for_context(extern_string, context); |
| 19072 | |
| 19073 | cod_subroutine_declaration("short proc(short p1, unsigned int p2)", |
| 19074 | context); |
| 19075 | gen_code = cod_code_gen(code, context); |
| 19076 | proc = (short (*)(short, unsigned int))(long)gen_code->func; |
| 19077 | |
| 19078 | |
| 19079 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 19080 | short source1_s = src1s_vals[i]; |
| 19081 | for (j=0 ; j < sizeof(sh_src2_vals)/sizeof(sh_src2_vals[0]) ; j++) { |
| 19082 | unsigned int source2_u = sh_src2_vals[j]; |
| 19083 | |
| 19084 | short expected_result; |
| 19085 | short result; |
| 19086 | |
| 19087 | if (source2_u >= sizeof(source1_s)) goto skip85; |
| 19088 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 19089 | |
| 19090 | expected_result = (short) (source1_s >> source2_u); |
| 19091 | |
| 19092 | result = proc(source1_s, source2_u); |
| 19093 | if (expected_result != result) { |
| 19094 | printf("Failed short >> unsigned int test, expected %d, got %d, for %d >> %u\n", |
| 19095 | expected_result, result, source1_s, source2_u); |
| 19096 | if (dumped == 0) cod_dump(gen_code); |
| 19097 | failed++; |
| 19098 | dumped++; |
| 19099 | } |
| 19100 | skip85: ; |
| 19101 | } |
| 19102 | } |
| 19103 | if (verbose) printf(" done\n"); |
| 19104 | cod_free_parse_context(context); |
| 19105 | cod_code_free(gen_code); |
| 19106 | } |
| 19107 | if ((only_run_test == NULL((void*)0)) || |
| 19108 | (strcmp(only_run_test, "s>>ul") == 0)) { |
| 19109 | int i, j; |
| 19110 | static char code[] = "{\n\ |
| 19111 | short a = p1;\n\ |
| 19112 | unsigned long b = p2;\n\ |
| 19113 | return a >> b;\n\ |
| 19114 | }"; |
| 19115 | |
| 19116 | short (*proc)(short a, unsigned long b); |
| 19117 | cod_parse_context context = new_cod_parse_context(); |
| 19118 | int dumped = 0; |
| 19119 | |
| 19120 | cod_code gen_code; |
| 19121 | |
| 19122 | /* test for short >> unsigned long */ |
| 19123 | if (verbose) printf("test for short >> unsigned long"); |
| 19124 | |
| 19125 | cod_assoc_externs(context, externs); |
| 19126 | cod_parse_for_context(extern_string, context); |
| 19127 | |
| 19128 | cod_subroutine_declaration("short proc(short p1, unsigned long p2)", |
| 19129 | context); |
| 19130 | gen_code = cod_code_gen(code, context); |
| 19131 | proc = (short (*)(short, unsigned long))(long)gen_code->func; |
| 19132 | |
| 19133 | |
| 19134 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 19135 | short source1_s = src1s_vals[i]; |
| 19136 | for (j=0 ; j < sizeof(sh_src2_vals)/sizeof(sh_src2_vals[0]) ; j++) { |
| 19137 | unsigned long source2_ul = sh_src2_vals[j]; |
| 19138 | |
| 19139 | short expected_result; |
| 19140 | short result; |
| 19141 | |
| 19142 | if (source2_ul >= sizeof(source1_s)) goto skip86; |
| 19143 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 19144 | |
| 19145 | expected_result = (short) (source1_s >> source2_ul); |
| 19146 | |
| 19147 | result = proc(source1_s, source2_ul); |
| 19148 | if (expected_result != result) { |
| 19149 | printf("Failed short >> unsigned long test, expected %d, got %d, for %d >> %lu\n", |
| 19150 | expected_result, result, source1_s, source2_ul); |
| 19151 | if (dumped == 0) cod_dump(gen_code); |
| 19152 | failed++; |
| 19153 | dumped++; |
| 19154 | } |
| 19155 | skip86: ; |
| 19156 | } |
| 19157 | } |
| 19158 | if (verbose) printf(" done\n"); |
| 19159 | cod_free_parse_context(context); |
| 19160 | cod_code_free(gen_code); |
| 19161 | } |
| 19162 | if ((only_run_test == NULL((void*)0)) || |
| 19163 | (strcmp(only_run_test, "s>>l") == 0)) { |
| 19164 | int i, j; |
| 19165 | static char code[] = "{\n\ |
| 19166 | short a = p1;\n\ |
| 19167 | long b = p2;\n\ |
| 19168 | return a >> b;\n\ |
| 19169 | }"; |
| 19170 | |
| 19171 | short (*proc)(short a, long b); |
| 19172 | cod_parse_context context = new_cod_parse_context(); |
| 19173 | int dumped = 0; |
| 19174 | |
| 19175 | cod_code gen_code; |
| 19176 | |
| 19177 | /* test for short >> long */ |
| 19178 | if (verbose) printf("test for short >> long"); |
| 19179 | |
| 19180 | cod_assoc_externs(context, externs); |
| 19181 | cod_parse_for_context(extern_string, context); |
| 19182 | |
| 19183 | cod_subroutine_declaration("short proc(short p1, long p2)", |
| 19184 | context); |
| 19185 | gen_code = cod_code_gen(code, context); |
| 19186 | proc = (short (*)(short, long))(long)gen_code->func; |
| 19187 | |
| 19188 | |
| 19189 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 19190 | short source1_s = src1s_vals[i]; |
| 19191 | for (j=0 ; j < sizeof(sh_src2_vals)/sizeof(sh_src2_vals[0]) ; j++) { |
| 19192 | long source2_l = sh_src2_vals[j]; |
| 19193 | |
| 19194 | short expected_result; |
| 19195 | short result; |
| 19196 | |
| 19197 | if (source2_l >= sizeof(source1_s)) goto skip87; |
| 19198 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 19199 | |
| 19200 | expected_result = (short) (source1_s >> source2_l); |
| 19201 | |
| 19202 | result = proc(source1_s, source2_l); |
| 19203 | if (expected_result != result) { |
| 19204 | printf("Failed short >> long test, expected %d, got %d, for %d >> %ld\n", |
| 19205 | expected_result, result, source1_s, source2_l); |
| 19206 | if (dumped == 0) cod_dump(gen_code); |
| 19207 | failed++; |
| 19208 | dumped++; |
| 19209 | } |
| 19210 | skip87: ; |
| 19211 | } |
| 19212 | } |
| 19213 | if (verbose) printf(" done\n"); |
| 19214 | cod_free_parse_context(context); |
| 19215 | cod_code_free(gen_code); |
| 19216 | } |
| 19217 | } |
| 19218 | void rsh_us_tests() |
| 19219 | { |
| 19220 | if ((only_run_test == NULL((void*)0)) || |
| 19221 | (strcmp(only_run_test, "us>>c") == 0)) { |
| 19222 | int i, j; |
| 19223 | static char code[] = "{\n\ |
| 19224 | unsigned short a = p1;\n\ |
| 19225 | signed char b = p2;\n\ |
| 19226 | return a >> b;\n\ |
| 19227 | }"; |
| 19228 | |
| 19229 | unsigned short (*proc)(unsigned short a, signed char b); |
| 19230 | cod_parse_context context = new_cod_parse_context(); |
| 19231 | int dumped = 0; |
| 19232 | |
| 19233 | cod_code gen_code; |
| 19234 | |
| 19235 | /* test for unsigned short >> signed char */ |
| 19236 | if (verbose) printf("test for unsigned short >> signed char"); |
| 19237 | |
| 19238 | cod_assoc_externs(context, externs); |
| 19239 | cod_parse_for_context(extern_string, context); |
| 19240 | |
| 19241 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, signed char p2)", |
| 19242 | context); |
| 19243 | gen_code = cod_code_gen(code, context); |
| 19244 | proc = (unsigned short (*)(unsigned short, signed char))(long)gen_code->func; |
| 19245 | |
| 19246 | |
| 19247 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 19248 | unsigned short source1_us = src1us_vals[i]; |
| 19249 | for (j=0 ; j < sizeof(sh_src2c_vals)/sizeof(sh_src2c_vals[0]) ; j++) { |
| 19250 | signed char source2_c = sh_src2c_vals[j]; |
| 19251 | |
| 19252 | unsigned short expected_result; |
| 19253 | unsigned short result; |
| 19254 | |
| 19255 | if (source2_c >= sizeof(source1_us)) goto skip88; |
| 19256 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 19257 | |
| 19258 | expected_result = (unsigned short) (source1_us >> source2_c); |
| 19259 | |
| 19260 | result = proc(source1_us, source2_c); |
| 19261 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 19262 | if (expected_result != result) { |
| 19263 | printf("Failed unsigned short >> signed char test, expected %u, got %u, for %u >> %d\n", |
| 19264 | expected_result, result, source1_us, source2_c); |
| 19265 | if (dumped == 0) cod_dump(gen_code); |
| 19266 | failed++; |
| 19267 | dumped++; |
| 19268 | } |
| 19269 | skip88: ; |
| 19270 | } |
| 19271 | } |
| 19272 | if (verbose) printf(" done\n"); |
| 19273 | cod_free_parse_context(context); |
| 19274 | cod_code_free(gen_code); |
| 19275 | } |
| 19276 | if ((only_run_test == NULL((void*)0)) || |
| 19277 | (strcmp(only_run_test, "us>>uc") == 0)) { |
| 19278 | int i, j; |
| 19279 | static char code[] = "{\n\ |
| 19280 | unsigned short a = p1;\n\ |
| 19281 | unsigned char b = p2;\n\ |
| 19282 | return a >> b;\n\ |
| 19283 | }"; |
| 19284 | |
| 19285 | unsigned short (*proc)(unsigned short a, unsigned char b); |
| 19286 | cod_parse_context context = new_cod_parse_context(); |
| 19287 | int dumped = 0; |
| 19288 | |
| 19289 | cod_code gen_code; |
| 19290 | |
| 19291 | /* test for unsigned short >> unsigned char */ |
| 19292 | if (verbose) printf("test for unsigned short >> unsigned char"); |
| 19293 | |
| 19294 | cod_assoc_externs(context, externs); |
| 19295 | cod_parse_for_context(extern_string, context); |
| 19296 | |
| 19297 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, unsigned char p2)", |
| 19298 | context); |
| 19299 | gen_code = cod_code_gen(code, context); |
| 19300 | proc = (unsigned short (*)(unsigned short, unsigned char))(long)gen_code->func; |
| 19301 | |
| 19302 | |
| 19303 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 19304 | unsigned short source1_us = src1us_vals[i]; |
| 19305 | for (j=0 ; j < sizeof(sh_src2c_vals)/sizeof(sh_src2c_vals[0]) ; j++) { |
| 19306 | unsigned char source2_uc = sh_src2c_vals[j]; |
| 19307 | |
| 19308 | unsigned short expected_result; |
| 19309 | unsigned short result; |
| 19310 | |
| 19311 | if (source2_uc >= sizeof(source1_us)) goto skip89; |
| 19312 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 19313 | |
| 19314 | expected_result = (unsigned short) (source1_us >> source2_uc); |
| 19315 | |
| 19316 | result = proc(source1_us, source2_uc); |
| 19317 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 19318 | if (expected_result != result) { |
| 19319 | printf("Failed unsigned short >> unsigned char test, expected %u, got %u, for %u >> %u\n", |
| 19320 | expected_result, result, source1_us, source2_uc); |
| 19321 | if (dumped == 0) cod_dump(gen_code); |
| 19322 | failed++; |
| 19323 | dumped++; |
| 19324 | } |
| 19325 | skip89: ; |
| 19326 | } |
| 19327 | } |
| 19328 | if (verbose) printf(" done\n"); |
| 19329 | cod_free_parse_context(context); |
| 19330 | cod_code_free(gen_code); |
| 19331 | } |
| 19332 | if ((only_run_test == NULL((void*)0)) || |
| 19333 | (strcmp(only_run_test, "us>>s") == 0)) { |
| 19334 | int i, j; |
| 19335 | static char code[] = "{\n\ |
| 19336 | unsigned short a = p1;\n\ |
| 19337 | short b = p2;\n\ |
| 19338 | return a >> b;\n\ |
| 19339 | }"; |
| 19340 | |
| 19341 | unsigned short (*proc)(unsigned short a, short b); |
| 19342 | cod_parse_context context = new_cod_parse_context(); |
| 19343 | int dumped = 0; |
| 19344 | |
| 19345 | cod_code gen_code; |
| 19346 | |
| 19347 | /* test for unsigned short >> short */ |
| 19348 | if (verbose) printf("test for unsigned short >> short"); |
| 19349 | |
| 19350 | cod_assoc_externs(context, externs); |
| 19351 | cod_parse_for_context(extern_string, context); |
| 19352 | |
| 19353 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, short p2)", |
| 19354 | context); |
| 19355 | gen_code = cod_code_gen(code, context); |
| 19356 | proc = (unsigned short (*)(unsigned short, short))(long)gen_code->func; |
| 19357 | |
| 19358 | |
| 19359 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 19360 | unsigned short source1_us = src1us_vals[i]; |
| 19361 | for (j=0 ; j < sizeof(sh_src2s_vals)/sizeof(sh_src2s_vals[0]) ; j++) { |
| 19362 | short source2_s = sh_src2s_vals[j]; |
| 19363 | |
| 19364 | unsigned short expected_result; |
| 19365 | unsigned short result; |
| 19366 | |
| 19367 | if (source2_s >= sizeof(source1_us)) goto skip90; |
| 19368 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 19369 | |
| 19370 | expected_result = (unsigned short) (source1_us >> source2_s); |
| 19371 | |
| 19372 | result = proc(source1_us, source2_s); |
| 19373 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 19374 | if (expected_result != result) { |
| 19375 | printf("Failed unsigned short >> short test, expected %u, got %u, for %u >> %d\n", |
| 19376 | expected_result, result, source1_us, source2_s); |
| 19377 | if (dumped == 0) cod_dump(gen_code); |
| 19378 | failed++; |
| 19379 | dumped++; |
| 19380 | } |
| 19381 | skip90: ; |
| 19382 | } |
| 19383 | } |
| 19384 | if (verbose) printf(" done\n"); |
| 19385 | cod_free_parse_context(context); |
| 19386 | cod_code_free(gen_code); |
| 19387 | } |
| 19388 | if ((only_run_test == NULL((void*)0)) || |
| 19389 | (strcmp(only_run_test, "us>>us") == 0)) { |
| 19390 | int i, j; |
| 19391 | static char code[] = "{\n\ |
| 19392 | unsigned short a = p1;\n\ |
| 19393 | unsigned short b = p2;\n\ |
| 19394 | return a >> b;\n\ |
| 19395 | }"; |
| 19396 | |
| 19397 | unsigned short (*proc)(unsigned short a, unsigned short b); |
| 19398 | cod_parse_context context = new_cod_parse_context(); |
| 19399 | int dumped = 0; |
| 19400 | |
| 19401 | cod_code gen_code; |
| 19402 | |
| 19403 | /* test for unsigned short >> unsigned short */ |
| 19404 | if (verbose) printf("test for unsigned short >> unsigned short"); |
| 19405 | |
| 19406 | cod_assoc_externs(context, externs); |
| 19407 | cod_parse_for_context(extern_string, context); |
| 19408 | |
| 19409 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, unsigned short p2)", |
| 19410 | context); |
| 19411 | gen_code = cod_code_gen(code, context); |
| 19412 | proc = (unsigned short (*)(unsigned short, unsigned short))(long)gen_code->func; |
| 19413 | |
| 19414 | |
| 19415 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 19416 | unsigned short source1_us = src1us_vals[i]; |
| 19417 | for (j=0 ; j < sizeof(sh_src2s_vals)/sizeof(sh_src2s_vals[0]) ; j++) { |
| 19418 | unsigned short source2_us = sh_src2s_vals[j]; |
| 19419 | |
| 19420 | unsigned short expected_result; |
| 19421 | unsigned short result; |
| 19422 | |
| 19423 | if (source2_us >= sizeof(source1_us)) goto skip91; |
| 19424 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 19425 | |
| 19426 | expected_result = (unsigned short) (source1_us >> source2_us); |
| 19427 | |
| 19428 | result = proc(source1_us, source2_us); |
| 19429 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 19430 | if (expected_result != result) { |
| 19431 | printf("Failed unsigned short >> unsigned short test, expected %u, got %u, for %u >> %u\n", |
| 19432 | expected_result, result, source1_us, source2_us); |
| 19433 | if (dumped == 0) cod_dump(gen_code); |
| 19434 | failed++; |
| 19435 | dumped++; |
| 19436 | } |
| 19437 | skip91: ; |
| 19438 | } |
| 19439 | } |
| 19440 | if (verbose) printf(" done\n"); |
| 19441 | cod_free_parse_context(context); |
| 19442 | cod_code_free(gen_code); |
| 19443 | } |
| 19444 | if ((only_run_test == NULL((void*)0)) || |
| 19445 | (strcmp(only_run_test, "us>>i") == 0)) { |
| 19446 | int i, j; |
| 19447 | static char code[] = "{\n\ |
| 19448 | unsigned short a = p1;\n\ |
| 19449 | int b = p2;\n\ |
| 19450 | return a >> b;\n\ |
| 19451 | }"; |
| 19452 | |
| 19453 | unsigned short (*proc)(unsigned short a, int b); |
| 19454 | cod_parse_context context = new_cod_parse_context(); |
| 19455 | int dumped = 0; |
| 19456 | |
| 19457 | cod_code gen_code; |
| 19458 | |
| 19459 | /* test for unsigned short >> int */ |
| 19460 | if (verbose) printf("test for unsigned short >> int"); |
| 19461 | |
| 19462 | cod_assoc_externs(context, externs); |
| 19463 | cod_parse_for_context(extern_string, context); |
| 19464 | |
| 19465 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, int p2)", |
| 19466 | context); |
| 19467 | gen_code = cod_code_gen(code, context); |
| 19468 | proc = (unsigned short (*)(unsigned short, int))(long)gen_code->func; |
| 19469 | |
| 19470 | |
| 19471 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 19472 | unsigned short source1_us = src1us_vals[i]; |
| 19473 | for (j=0 ; j < sizeof(sh_src2_vals)/sizeof(sh_src2_vals[0]) ; j++) { |
| 19474 | int source2_i = sh_src2_vals[j]; |
| 19475 | |
| 19476 | unsigned short expected_result; |
| 19477 | unsigned short result; |
| 19478 | |
| 19479 | if (source2_i >= sizeof(source1_us)) goto skip92; |
| 19480 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 19481 | |
| 19482 | expected_result = (unsigned short) (source1_us >> source2_i); |
| 19483 | |
| 19484 | result = proc(source1_us, source2_i); |
| 19485 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 19486 | if (expected_result != result) { |
| 19487 | printf("Failed unsigned short >> int test, expected %u, got %u, for %u >> %d\n", |
| 19488 | expected_result, result, source1_us, source2_i); |
| 19489 | if (dumped == 0) cod_dump(gen_code); |
| 19490 | failed++; |
| 19491 | dumped++; |
| 19492 | } |
| 19493 | skip92: ; |
| 19494 | } |
| 19495 | } |
| 19496 | if (verbose) printf(" done\n"); |
| 19497 | cod_free_parse_context(context); |
| 19498 | cod_code_free(gen_code); |
| 19499 | } |
| 19500 | if ((only_run_test == NULL((void*)0)) || |
| 19501 | (strcmp(only_run_test, "us>>u") == 0)) { |
| 19502 | int i, j; |
| 19503 | static char code[] = "{\n\ |
| 19504 | unsigned short a = p1;\n\ |
| 19505 | unsigned int b = p2;\n\ |
| 19506 | return a >> b;\n\ |
| 19507 | }"; |
| 19508 | |
| 19509 | unsigned short (*proc)(unsigned short a, unsigned int b); |
| 19510 | cod_parse_context context = new_cod_parse_context(); |
| 19511 | int dumped = 0; |
| 19512 | |
| 19513 | cod_code gen_code; |
| 19514 | |
| 19515 | /* test for unsigned short >> unsigned int */ |
| 19516 | if (verbose) printf("test for unsigned short >> unsigned int"); |
| 19517 | |
| 19518 | cod_assoc_externs(context, externs); |
| 19519 | cod_parse_for_context(extern_string, context); |
| 19520 | |
| 19521 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, unsigned int p2)", |
| 19522 | context); |
| 19523 | gen_code = cod_code_gen(code, context); |
| 19524 | proc = (unsigned short (*)(unsigned short, unsigned int))(long)gen_code->func; |
| 19525 | |
| 19526 | |
| 19527 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 19528 | unsigned short source1_us = src1us_vals[i]; |
| 19529 | for (j=0 ; j < sizeof(sh_src2_vals)/sizeof(sh_src2_vals[0]) ; j++) { |
| 19530 | unsigned int source2_u = sh_src2_vals[j]; |
| 19531 | |
| 19532 | unsigned short expected_result; |
| 19533 | unsigned short result; |
| 19534 | |
| 19535 | if (source2_u >= sizeof(source1_us)) goto skip93; |
| 19536 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 19537 | |
| 19538 | expected_result = (unsigned short) (source1_us >> source2_u); |
| 19539 | |
| 19540 | result = proc(source1_us, source2_u); |
| 19541 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 19542 | if (expected_result != result) { |
| 19543 | printf("Failed unsigned short >> unsigned int test, expected %u, got %u, for %u >> %u\n", |
| 19544 | expected_result, result, source1_us, source2_u); |
| 19545 | if (dumped == 0) cod_dump(gen_code); |
| 19546 | failed++; |
| 19547 | dumped++; |
| 19548 | } |
| 19549 | skip93: ; |
| 19550 | } |
| 19551 | } |
| 19552 | if (verbose) printf(" done\n"); |
| 19553 | cod_free_parse_context(context); |
| 19554 | cod_code_free(gen_code); |
| 19555 | } |
| 19556 | if ((only_run_test == NULL((void*)0)) || |
| 19557 | (strcmp(only_run_test, "us>>ul") == 0)) { |
| 19558 | int i, j; |
| 19559 | static char code[] = "{\n\ |
| 19560 | unsigned short a = p1;\n\ |
| 19561 | unsigned long b = p2;\n\ |
| 19562 | return a >> b;\n\ |
| 19563 | }"; |
| 19564 | |
| 19565 | unsigned short (*proc)(unsigned short a, unsigned long b); |
| 19566 | cod_parse_context context = new_cod_parse_context(); |
| 19567 | int dumped = 0; |
| 19568 | |
| 19569 | cod_code gen_code; |
| 19570 | |
| 19571 | /* test for unsigned short >> unsigned long */ |
| 19572 | if (verbose) printf("test for unsigned short >> unsigned long"); |
| 19573 | |
| 19574 | cod_assoc_externs(context, externs); |
| 19575 | cod_parse_for_context(extern_string, context); |
| 19576 | |
| 19577 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, unsigned long p2)", |
| 19578 | context); |
| 19579 | gen_code = cod_code_gen(code, context); |
| 19580 | proc = (unsigned short (*)(unsigned short, unsigned long))(long)gen_code->func; |
| 19581 | |
| 19582 | |
| 19583 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 19584 | unsigned short source1_us = src1us_vals[i]; |
| 19585 | for (j=0 ; j < sizeof(sh_src2_vals)/sizeof(sh_src2_vals[0]) ; j++) { |
| 19586 | unsigned long source2_ul = sh_src2_vals[j]; |
| 19587 | |
| 19588 | unsigned short expected_result; |
| 19589 | unsigned short result; |
| 19590 | |
| 19591 | if (source2_ul >= sizeof(source1_us)) goto skip94; |
| 19592 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 19593 | |
| 19594 | expected_result = (unsigned short) (source1_us >> source2_ul); |
| 19595 | |
| 19596 | result = proc(source1_us, source2_ul); |
| 19597 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 19598 | if (expected_result != result) { |
| 19599 | printf("Failed unsigned short >> unsigned long test, expected %u, got %u, for %u >> %lu\n", |
| 19600 | expected_result, result, source1_us, source2_ul); |
| 19601 | if (dumped == 0) cod_dump(gen_code); |
| 19602 | failed++; |
| 19603 | dumped++; |
| 19604 | } |
| 19605 | skip94: ; |
| 19606 | } |
| 19607 | } |
| 19608 | if (verbose) printf(" done\n"); |
| 19609 | cod_free_parse_context(context); |
| 19610 | cod_code_free(gen_code); |
| 19611 | } |
| 19612 | if ((only_run_test == NULL((void*)0)) || |
| 19613 | (strcmp(only_run_test, "us>>l") == 0)) { |
| 19614 | int i, j; |
| 19615 | static char code[] = "{\n\ |
| 19616 | unsigned short a = p1;\n\ |
| 19617 | long b = p2;\n\ |
| 19618 | return a >> b;\n\ |
| 19619 | }"; |
| 19620 | |
| 19621 | unsigned short (*proc)(unsigned short a, long b); |
| 19622 | cod_parse_context context = new_cod_parse_context(); |
| 19623 | int dumped = 0; |
| 19624 | |
| 19625 | cod_code gen_code; |
| 19626 | |
| 19627 | /* test for unsigned short >> long */ |
| 19628 | if (verbose) printf("test for unsigned short >> long"); |
| 19629 | |
| 19630 | cod_assoc_externs(context, externs); |
| 19631 | cod_parse_for_context(extern_string, context); |
| 19632 | |
| 19633 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, long p2)", |
| 19634 | context); |
| 19635 | gen_code = cod_code_gen(code, context); |
| 19636 | proc = (unsigned short (*)(unsigned short, long))(long)gen_code->func; |
| 19637 | |
| 19638 | |
| 19639 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 19640 | unsigned short source1_us = src1us_vals[i]; |
| 19641 | for (j=0 ; j < sizeof(sh_src2_vals)/sizeof(sh_src2_vals[0]) ; j++) { |
| 19642 | long source2_l = sh_src2_vals[j]; |
| 19643 | |
| 19644 | unsigned short expected_result; |
| 19645 | unsigned short result; |
| 19646 | |
| 19647 | if (source2_l >= sizeof(source1_us)) goto skip95; |
| 19648 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 19649 | |
| 19650 | expected_result = (unsigned short) (source1_us >> source2_l); |
| 19651 | |
| 19652 | result = proc(source1_us, source2_l); |
| 19653 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 19654 | if (expected_result != result) { |
| 19655 | printf("Failed unsigned short >> long test, expected %u, got %u, for %u >> %ld\n", |
| 19656 | expected_result, result, source1_us, source2_l); |
| 19657 | if (dumped == 0) cod_dump(gen_code); |
| 19658 | failed++; |
| 19659 | dumped++; |
| 19660 | } |
| 19661 | skip95: ; |
| 19662 | } |
| 19663 | } |
| 19664 | if (verbose) printf(" done\n"); |
| 19665 | cod_free_parse_context(context); |
| 19666 | cod_code_free(gen_code); |
| 19667 | } |
| 19668 | } |
| 19669 | void rsh_i_tests() |
| 19670 | { |
| 19671 | if ((only_run_test == NULL((void*)0)) || |
| 19672 | (strcmp(only_run_test, "i>>c") == 0)) { |
| 19673 | int i, j; |
| 19674 | static char code[] = "{\n\ |
| 19675 | int a = p1;\n\ |
| 19676 | signed char b = p2;\n\ |
| 19677 | return a >> b;\n\ |
| 19678 | }"; |
| 19679 | |
| 19680 | int (*proc)(int a, signed char b); |
| 19681 | cod_parse_context context = new_cod_parse_context(); |
| 19682 | int dumped = 0; |
| 19683 | |
| 19684 | cod_code gen_code; |
| 19685 | |
| 19686 | /* test for int >> signed char */ |
| 19687 | if (verbose) printf("test for int >> signed char"); |
| 19688 | |
| 19689 | cod_assoc_externs(context, externs); |
| 19690 | cod_parse_for_context(extern_string, context); |
| 19691 | |
| 19692 | cod_subroutine_declaration("int proc(int p1, signed char p2)", |
| 19693 | context); |
| 19694 | gen_code = cod_code_gen(code, context); |
| 19695 | proc = (int (*)(int, signed char))(long)gen_code->func; |
| 19696 | |
| 19697 | |
| 19698 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 19699 | int source1_i = src1i_vals[i]; |
| 19700 | for (j=0 ; j < sizeof(sh_src2c_vals)/sizeof(sh_src2c_vals[0]) ; j++) { |
| 19701 | signed char source2_c = sh_src2c_vals[j]; |
| 19702 | |
| 19703 | int expected_result; |
| 19704 | int result; |
| 19705 | |
| 19706 | if (source2_c >= sizeof(source1_i)) goto skip96; |
| 19707 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 19708 | |
| 19709 | expected_result = (int) (source1_i >> source2_c); |
| 19710 | |
| 19711 | result = proc(source1_i, source2_c); |
| 19712 | if (expected_result != result) { |
| 19713 | printf("Failed int >> signed char test, expected %d, got %d, for %d >> %d\n", |
| 19714 | expected_result, result, source1_i, source2_c); |
| 19715 | if (dumped == 0) cod_dump(gen_code); |
| 19716 | failed++; |
| 19717 | dumped++; |
| 19718 | } |
| 19719 | skip96: ; |
| 19720 | } |
| 19721 | } |
| 19722 | if (verbose) printf(" done\n"); |
| 19723 | cod_free_parse_context(context); |
| 19724 | cod_code_free(gen_code); |
| 19725 | } |
| 19726 | if ((only_run_test == NULL((void*)0)) || |
| 19727 | (strcmp(only_run_test, "i>>uc") == 0)) { |
| 19728 | int i, j; |
| 19729 | static char code[] = "{\n\ |
| 19730 | int a = p1;\n\ |
| 19731 | unsigned char b = p2;\n\ |
| 19732 | return a >> b;\n\ |
| 19733 | }"; |
| 19734 | |
| 19735 | int (*proc)(int a, unsigned char b); |
| 19736 | cod_parse_context context = new_cod_parse_context(); |
| 19737 | int dumped = 0; |
| 19738 | |
| 19739 | cod_code gen_code; |
| 19740 | |
| 19741 | /* test for int >> unsigned char */ |
| 19742 | if (verbose) printf("test for int >> unsigned char"); |
| 19743 | |
| 19744 | cod_assoc_externs(context, externs); |
| 19745 | cod_parse_for_context(extern_string, context); |
| 19746 | |
| 19747 | cod_subroutine_declaration("int proc(int p1, unsigned char p2)", |
| 19748 | context); |
| 19749 | gen_code = cod_code_gen(code, context); |
| 19750 | proc = (int (*)(int, unsigned char))(long)gen_code->func; |
| 19751 | |
| 19752 | |
| 19753 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 19754 | int source1_i = src1i_vals[i]; |
| 19755 | for (j=0 ; j < sizeof(sh_src2c_vals)/sizeof(sh_src2c_vals[0]) ; j++) { |
| 19756 | unsigned char source2_uc = sh_src2c_vals[j]; |
| 19757 | |
| 19758 | int expected_result; |
| 19759 | int result; |
| 19760 | |
| 19761 | if (source2_uc >= sizeof(source1_i)) goto skip97; |
| 19762 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 19763 | |
| 19764 | expected_result = (int) (source1_i >> source2_uc); |
| 19765 | |
| 19766 | result = proc(source1_i, source2_uc); |
| 19767 | if (expected_result != result) { |
| 19768 | printf("Failed int >> unsigned char test, expected %d, got %d, for %d >> %u\n", |
| 19769 | expected_result, result, source1_i, source2_uc); |
| 19770 | if (dumped == 0) cod_dump(gen_code); |
| 19771 | failed++; |
| 19772 | dumped++; |
| 19773 | } |
| 19774 | skip97: ; |
| 19775 | } |
| 19776 | } |
| 19777 | if (verbose) printf(" done\n"); |
| 19778 | cod_free_parse_context(context); |
| 19779 | cod_code_free(gen_code); |
| 19780 | } |
| 19781 | if ((only_run_test == NULL((void*)0)) || |
| 19782 | (strcmp(only_run_test, "i>>s") == 0)) { |
| 19783 | int i, j; |
| 19784 | static char code[] = "{\n\ |
| 19785 | int a = p1;\n\ |
| 19786 | short b = p2;\n\ |
| 19787 | return a >> b;\n\ |
| 19788 | }"; |
| 19789 | |
| 19790 | int (*proc)(int a, short b); |
| 19791 | cod_parse_context context = new_cod_parse_context(); |
| 19792 | int dumped = 0; |
| 19793 | |
| 19794 | cod_code gen_code; |
| 19795 | |
| 19796 | /* test for int >> short */ |
| 19797 | if (verbose) printf("test for int >> short"); |
| 19798 | |
| 19799 | cod_assoc_externs(context, externs); |
| 19800 | cod_parse_for_context(extern_string, context); |
| 19801 | |
| 19802 | cod_subroutine_declaration("int proc(int p1, short p2)", |
| 19803 | context); |
| 19804 | gen_code = cod_code_gen(code, context); |
| 19805 | proc = (int (*)(int, short))(long)gen_code->func; |
| 19806 | |
| 19807 | |
| 19808 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 19809 | int source1_i = src1i_vals[i]; |
| 19810 | for (j=0 ; j < sizeof(sh_src2s_vals)/sizeof(sh_src2s_vals[0]) ; j++) { |
| 19811 | short source2_s = sh_src2s_vals[j]; |
| 19812 | |
| 19813 | int expected_result; |
| 19814 | int result; |
| 19815 | |
| 19816 | if (source2_s >= sizeof(source1_i)) goto skip98; |
| 19817 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 19818 | |
| 19819 | expected_result = (int) (source1_i >> source2_s); |
| 19820 | |
| 19821 | result = proc(source1_i, source2_s); |
| 19822 | if (expected_result != result) { |
| 19823 | printf("Failed int >> short test, expected %d, got %d, for %d >> %d\n", |
| 19824 | expected_result, result, source1_i, source2_s); |
| 19825 | if (dumped == 0) cod_dump(gen_code); |
| 19826 | failed++; |
| 19827 | dumped++; |
| 19828 | } |
| 19829 | skip98: ; |
| 19830 | } |
| 19831 | } |
| 19832 | if (verbose) printf(" done\n"); |
| 19833 | cod_free_parse_context(context); |
| 19834 | cod_code_free(gen_code); |
| 19835 | } |
| 19836 | if ((only_run_test == NULL((void*)0)) || |
| 19837 | (strcmp(only_run_test, "i>>us") == 0)) { |
| 19838 | int i, j; |
| 19839 | static char code[] = "{\n\ |
| 19840 | int a = p1;\n\ |
| 19841 | unsigned short b = p2;\n\ |
| 19842 | return a >> b;\n\ |
| 19843 | }"; |
| 19844 | |
| 19845 | int (*proc)(int a, unsigned short b); |
| 19846 | cod_parse_context context = new_cod_parse_context(); |
| 19847 | int dumped = 0; |
| 19848 | |
| 19849 | cod_code gen_code; |
| 19850 | |
| 19851 | /* test for int >> unsigned short */ |
| 19852 | if (verbose) printf("test for int >> unsigned short"); |
| 19853 | |
| 19854 | cod_assoc_externs(context, externs); |
| 19855 | cod_parse_for_context(extern_string, context); |
| 19856 | |
| 19857 | cod_subroutine_declaration("int proc(int p1, unsigned short p2)", |
| 19858 | context); |
| 19859 | gen_code = cod_code_gen(code, context); |
| 19860 | proc = (int (*)(int, unsigned short))(long)gen_code->func; |
| 19861 | |
| 19862 | |
| 19863 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 19864 | int source1_i = src1i_vals[i]; |
| 19865 | for (j=0 ; j < sizeof(sh_src2s_vals)/sizeof(sh_src2s_vals[0]) ; j++) { |
| 19866 | unsigned short source2_us = sh_src2s_vals[j]; |
| 19867 | |
| 19868 | int expected_result; |
| 19869 | int result; |
| 19870 | |
| 19871 | if (source2_us >= sizeof(source1_i)) goto skip99; |
| 19872 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 19873 | |
| 19874 | expected_result = (int) (source1_i >> source2_us); |
| 19875 | |
| 19876 | result = proc(source1_i, source2_us); |
| 19877 | if (expected_result != result) { |
| 19878 | printf("Failed int >> unsigned short test, expected %d, got %d, for %d >> %u\n", |
| 19879 | expected_result, result, source1_i, source2_us); |
| 19880 | if (dumped == 0) cod_dump(gen_code); |
| 19881 | failed++; |
| 19882 | dumped++; |
| 19883 | } |
| 19884 | skip99: ; |
| 19885 | } |
| 19886 | } |
| 19887 | if (verbose) printf(" done\n"); |
| 19888 | cod_free_parse_context(context); |
| 19889 | cod_code_free(gen_code); |
| 19890 | } |
| 19891 | if ((only_run_test == NULL((void*)0)) || |
| 19892 | (strcmp(only_run_test, "i>>i") == 0)) { |
| 19893 | int i, j; |
| 19894 | static char code[] = "{\n\ |
| 19895 | int a = p1;\n\ |
| 19896 | int b = p2;\n\ |
| 19897 | return a >> b;\n\ |
| 19898 | }"; |
| 19899 | |
| 19900 | int (*proc)(int a, int b); |
| 19901 | cod_parse_context context = new_cod_parse_context(); |
| 19902 | int dumped = 0; |
| 19903 | |
| 19904 | cod_code gen_code; |
| 19905 | |
| 19906 | /* test for int >> int */ |
| 19907 | if (verbose) printf("test for int >> int"); |
| 19908 | |
| 19909 | cod_assoc_externs(context, externs); |
| 19910 | cod_parse_for_context(extern_string, context); |
| 19911 | |
| 19912 | cod_subroutine_declaration("int proc(int p1, int p2)", |
| 19913 | context); |
| 19914 | gen_code = cod_code_gen(code, context); |
| 19915 | proc = (int (*)(int, int))(long)gen_code->func; |
| 19916 | |
| 19917 | |
| 19918 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 19919 | int source1_i = src1i_vals[i]; |
| 19920 | for (j=0 ; j < sizeof(sh_src2_vals)/sizeof(sh_src2_vals[0]) ; j++) { |
| 19921 | int source2_i = sh_src2_vals[j]; |
| 19922 | |
| 19923 | int expected_result; |
| 19924 | int result; |
| 19925 | |
| 19926 | if (source2_i >= sizeof(source1_i)) goto skip100; |
| 19927 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 19928 | |
| 19929 | expected_result = (int) (source1_i >> source2_i); |
| 19930 | |
| 19931 | result = proc(source1_i, source2_i); |
| 19932 | if (expected_result != result) { |
| 19933 | printf("Failed int >> int test, expected %d, got %d, for %d >> %d\n", |
| 19934 | expected_result, result, source1_i, source2_i); |
| 19935 | if (dumped == 0) cod_dump(gen_code); |
| 19936 | failed++; |
| 19937 | dumped++; |
| 19938 | } |
| 19939 | skip100: ; |
| 19940 | } |
| 19941 | } |
| 19942 | if (verbose) printf(" done\n"); |
| 19943 | cod_free_parse_context(context); |
| 19944 | cod_code_free(gen_code); |
| 19945 | } |
| 19946 | if ((only_run_test == NULL((void*)0)) || |
| 19947 | (strcmp(only_run_test, "i>>u") == 0)) { |
| 19948 | int i, j; |
| 19949 | static char code[] = "{\n\ |
| 19950 | int a = p1;\n\ |
| 19951 | unsigned int b = p2;\n\ |
| 19952 | return a >> b;\n\ |
| 19953 | }"; |
| 19954 | |
| 19955 | int (*proc)(int a, unsigned int b); |
| 19956 | cod_parse_context context = new_cod_parse_context(); |
| 19957 | int dumped = 0; |
| 19958 | |
| 19959 | cod_code gen_code; |
| 19960 | |
| 19961 | /* test for int >> unsigned int */ |
| 19962 | if (verbose) printf("test for int >> unsigned int"); |
| 19963 | |
| 19964 | cod_assoc_externs(context, externs); |
| 19965 | cod_parse_for_context(extern_string, context); |
| 19966 | |
| 19967 | cod_subroutine_declaration("int proc(int p1, unsigned int p2)", |
| 19968 | context); |
| 19969 | gen_code = cod_code_gen(code, context); |
| 19970 | proc = (int (*)(int, unsigned int))(long)gen_code->func; |
| 19971 | |
| 19972 | |
| 19973 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 19974 | int source1_i = src1i_vals[i]; |
| 19975 | for (j=0 ; j < sizeof(sh_src2_vals)/sizeof(sh_src2_vals[0]) ; j++) { |
| 19976 | unsigned int source2_u = sh_src2_vals[j]; |
| 19977 | |
| 19978 | int expected_result; |
| 19979 | int result; |
| 19980 | |
| 19981 | if (source2_u >= sizeof(source1_i)) goto skip101; |
| 19982 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 19983 | |
| 19984 | expected_result = (int) (source1_i >> source2_u); |
| 19985 | |
| 19986 | result = proc(source1_i, source2_u); |
| 19987 | if (expected_result != result) { |
| 19988 | printf("Failed int >> unsigned int test, expected %d, got %d, for %d >> %u\n", |
| 19989 | expected_result, result, source1_i, source2_u); |
| 19990 | if (dumped == 0) cod_dump(gen_code); |
| 19991 | failed++; |
| 19992 | dumped++; |
| 19993 | } |
| 19994 | skip101: ; |
| 19995 | } |
| 19996 | } |
| 19997 | if (verbose) printf(" done\n"); |
| 19998 | cod_free_parse_context(context); |
| 19999 | cod_code_free(gen_code); |
| 20000 | } |
| 20001 | if ((only_run_test == NULL((void*)0)) || |
| 20002 | (strcmp(only_run_test, "i>>ul") == 0)) { |
| 20003 | int i, j; |
| 20004 | static char code[] = "{\n\ |
| 20005 | int a = p1;\n\ |
| 20006 | unsigned long b = p2;\n\ |
| 20007 | return a >> b;\n\ |
| 20008 | }"; |
| 20009 | |
| 20010 | int (*proc)(int a, unsigned long b); |
| 20011 | cod_parse_context context = new_cod_parse_context(); |
| 20012 | int dumped = 0; |
| 20013 | |
| 20014 | cod_code gen_code; |
| 20015 | |
| 20016 | /* test for int >> unsigned long */ |
| 20017 | if (verbose) printf("test for int >> unsigned long"); |
| 20018 | |
| 20019 | cod_assoc_externs(context, externs); |
| 20020 | cod_parse_for_context(extern_string, context); |
| 20021 | |
| 20022 | cod_subroutine_declaration("int proc(int p1, unsigned long p2)", |
| 20023 | context); |
| 20024 | gen_code = cod_code_gen(code, context); |
| 20025 | proc = (int (*)(int, unsigned long))(long)gen_code->func; |
| 20026 | |
| 20027 | |
| 20028 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 20029 | int source1_i = src1i_vals[i]; |
| 20030 | for (j=0 ; j < sizeof(sh_src2_vals)/sizeof(sh_src2_vals[0]) ; j++) { |
| 20031 | unsigned long source2_ul = sh_src2_vals[j]; |
| 20032 | |
| 20033 | int expected_result; |
| 20034 | int result; |
| 20035 | |
| 20036 | if (source2_ul >= sizeof(source1_i)) goto skip102; |
| 20037 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 20038 | |
| 20039 | expected_result = (int) (source1_i >> source2_ul); |
| 20040 | |
| 20041 | result = proc(source1_i, source2_ul); |
| 20042 | if (expected_result != result) { |
| 20043 | printf("Failed int >> unsigned long test, expected %d, got %d, for %d >> %lu\n", |
| 20044 | expected_result, result, source1_i, source2_ul); |
| 20045 | if (dumped == 0) cod_dump(gen_code); |
| 20046 | failed++; |
| 20047 | dumped++; |
| 20048 | } |
| 20049 | skip102: ; |
| 20050 | } |
| 20051 | } |
| 20052 | if (verbose) printf(" done\n"); |
| 20053 | cod_free_parse_context(context); |
| 20054 | cod_code_free(gen_code); |
| 20055 | } |
| 20056 | if ((only_run_test == NULL((void*)0)) || |
| 20057 | (strcmp(only_run_test, "i>>l") == 0)) { |
| 20058 | int i, j; |
| 20059 | static char code[] = "{\n\ |
| 20060 | int a = p1;\n\ |
| 20061 | long b = p2;\n\ |
| 20062 | return a >> b;\n\ |
| 20063 | }"; |
| 20064 | |
| 20065 | int (*proc)(int a, long b); |
| 20066 | cod_parse_context context = new_cod_parse_context(); |
| 20067 | int dumped = 0; |
| 20068 | |
| 20069 | cod_code gen_code; |
| 20070 | |
| 20071 | /* test for int >> long */ |
| 20072 | if (verbose) printf("test for int >> long"); |
| 20073 | |
| 20074 | cod_assoc_externs(context, externs); |
| 20075 | cod_parse_for_context(extern_string, context); |
| 20076 | |
| 20077 | cod_subroutine_declaration("int proc(int p1, long p2)", |
| 20078 | context); |
| 20079 | gen_code = cod_code_gen(code, context); |
| 20080 | proc = (int (*)(int, long))(long)gen_code->func; |
| 20081 | |
| 20082 | |
| 20083 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 20084 | int source1_i = src1i_vals[i]; |
| 20085 | for (j=0 ; j < sizeof(sh_src2_vals)/sizeof(sh_src2_vals[0]) ; j++) { |
| 20086 | long source2_l = sh_src2_vals[j]; |
| 20087 | |
| 20088 | int expected_result; |
| 20089 | int result; |
| 20090 | |
| 20091 | if (source2_l >= sizeof(source1_i)) goto skip103; |
| 20092 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 20093 | |
| 20094 | expected_result = (int) (source1_i >> source2_l); |
| 20095 | |
| 20096 | result = proc(source1_i, source2_l); |
| 20097 | if (expected_result != result) { |
| 20098 | printf("Failed int >> long test, expected %d, got %d, for %d >> %ld\n", |
| 20099 | expected_result, result, source1_i, source2_l); |
| 20100 | if (dumped == 0) cod_dump(gen_code); |
| 20101 | failed++; |
| 20102 | dumped++; |
| 20103 | } |
| 20104 | skip103: ; |
| 20105 | } |
| 20106 | } |
| 20107 | if (verbose) printf(" done\n"); |
| 20108 | cod_free_parse_context(context); |
| 20109 | cod_code_free(gen_code); |
| 20110 | } |
| 20111 | } |
| 20112 | void rsh_u_tests() |
| 20113 | { |
| 20114 | if ((only_run_test == NULL((void*)0)) || |
| 20115 | (strcmp(only_run_test, "u>>c") == 0)) { |
| 20116 | int i, j; |
| 20117 | static char code[] = "{\n\ |
| 20118 | unsigned int a = p1;\n\ |
| 20119 | signed char b = p2;\n\ |
| 20120 | return a >> b;\n\ |
| 20121 | }"; |
| 20122 | |
| 20123 | unsigned int (*proc)(unsigned int a, signed char b); |
| 20124 | cod_parse_context context = new_cod_parse_context(); |
| 20125 | int dumped = 0; |
| 20126 | |
| 20127 | cod_code gen_code; |
| 20128 | |
| 20129 | /* test for unsigned int >> signed char */ |
| 20130 | if (verbose) printf("test for unsigned int >> signed char"); |
| 20131 | |
| 20132 | cod_assoc_externs(context, externs); |
| 20133 | cod_parse_for_context(extern_string, context); |
| 20134 | |
| 20135 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, signed char p2)", |
| 20136 | context); |
| 20137 | gen_code = cod_code_gen(code, context); |
| 20138 | proc = (unsigned int (*)(unsigned int, signed char))(long)gen_code->func; |
| 20139 | |
| 20140 | |
| 20141 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 20142 | unsigned int source1_u = src1u_vals[i]; |
| 20143 | for (j=0 ; j < sizeof(sh_src2c_vals)/sizeof(sh_src2c_vals[0]) ; j++) { |
| 20144 | signed char source2_c = sh_src2c_vals[j]; |
| 20145 | |
| 20146 | unsigned int expected_result; |
| 20147 | unsigned int result; |
| 20148 | |
| 20149 | if (source2_c >= sizeof(source1_u)) goto skip104; |
| 20150 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 20151 | |
| 20152 | expected_result = (unsigned int) (source1_u >> source2_c); |
| 20153 | |
| 20154 | result = proc(source1_u, source2_c); |
| 20155 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 20156 | if (expected_result != result) { |
| 20157 | printf("Failed unsigned int >> signed char test, expected %u, got %u, for %u >> %d\n", |
| 20158 | expected_result, result, source1_u, source2_c); |
| 20159 | if (dumped == 0) cod_dump(gen_code); |
| 20160 | failed++; |
| 20161 | dumped++; |
| 20162 | } |
| 20163 | skip104: ; |
| 20164 | } |
| 20165 | } |
| 20166 | if (verbose) printf(" done\n"); |
| 20167 | cod_free_parse_context(context); |
| 20168 | cod_code_free(gen_code); |
| 20169 | } |
| 20170 | if ((only_run_test == NULL((void*)0)) || |
| 20171 | (strcmp(only_run_test, "u>>uc") == 0)) { |
| 20172 | int i, j; |
| 20173 | static char code[] = "{\n\ |
| 20174 | unsigned int a = p1;\n\ |
| 20175 | unsigned char b = p2;\n\ |
| 20176 | return a >> b;\n\ |
| 20177 | }"; |
| 20178 | |
| 20179 | unsigned int (*proc)(unsigned int a, unsigned char b); |
| 20180 | cod_parse_context context = new_cod_parse_context(); |
| 20181 | int dumped = 0; |
| 20182 | |
| 20183 | cod_code gen_code; |
| 20184 | |
| 20185 | /* test for unsigned int >> unsigned char */ |
| 20186 | if (verbose) printf("test for unsigned int >> unsigned char"); |
| 20187 | |
| 20188 | cod_assoc_externs(context, externs); |
| 20189 | cod_parse_for_context(extern_string, context); |
| 20190 | |
| 20191 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, unsigned char p2)", |
| 20192 | context); |
| 20193 | gen_code = cod_code_gen(code, context); |
| 20194 | proc = (unsigned int (*)(unsigned int, unsigned char))(long)gen_code->func; |
| 20195 | |
| 20196 | |
| 20197 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 20198 | unsigned int source1_u = src1u_vals[i]; |
| 20199 | for (j=0 ; j < sizeof(sh_src2c_vals)/sizeof(sh_src2c_vals[0]) ; j++) { |
| 20200 | unsigned char source2_uc = sh_src2c_vals[j]; |
| 20201 | |
| 20202 | unsigned int expected_result; |
| 20203 | unsigned int result; |
| 20204 | |
| 20205 | if (source2_uc >= sizeof(source1_u)) goto skip105; |
| 20206 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 20207 | |
| 20208 | expected_result = (unsigned int) (source1_u >> source2_uc); |
| 20209 | |
| 20210 | result = proc(source1_u, source2_uc); |
| 20211 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 20212 | if (expected_result != result) { |
| 20213 | printf("Failed unsigned int >> unsigned char test, expected %u, got %u, for %u >> %u\n", |
| 20214 | expected_result, result, source1_u, source2_uc); |
| 20215 | if (dumped == 0) cod_dump(gen_code); |
| 20216 | failed++; |
| 20217 | dumped++; |
| 20218 | } |
| 20219 | skip105: ; |
| 20220 | } |
| 20221 | } |
| 20222 | if (verbose) printf(" done\n"); |
| 20223 | cod_free_parse_context(context); |
| 20224 | cod_code_free(gen_code); |
| 20225 | } |
| 20226 | if ((only_run_test == NULL((void*)0)) || |
| 20227 | (strcmp(only_run_test, "u>>s") == 0)) { |
| 20228 | int i, j; |
| 20229 | static char code[] = "{\n\ |
| 20230 | unsigned int a = p1;\n\ |
| 20231 | short b = p2;\n\ |
| 20232 | return a >> b;\n\ |
| 20233 | }"; |
| 20234 | |
| 20235 | unsigned int (*proc)(unsigned int a, short b); |
| 20236 | cod_parse_context context = new_cod_parse_context(); |
| 20237 | int dumped = 0; |
| 20238 | |
| 20239 | cod_code gen_code; |
| 20240 | |
| 20241 | /* test for unsigned int >> short */ |
| 20242 | if (verbose) printf("test for unsigned int >> short"); |
| 20243 | |
| 20244 | cod_assoc_externs(context, externs); |
| 20245 | cod_parse_for_context(extern_string, context); |
| 20246 | |
| 20247 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, short p2)", |
| 20248 | context); |
| 20249 | gen_code = cod_code_gen(code, context); |
| 20250 | proc = (unsigned int (*)(unsigned int, short))(long)gen_code->func; |
| 20251 | |
| 20252 | |
| 20253 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 20254 | unsigned int source1_u = src1u_vals[i]; |
| 20255 | for (j=0 ; j < sizeof(sh_src2s_vals)/sizeof(sh_src2s_vals[0]) ; j++) { |
| 20256 | short source2_s = sh_src2s_vals[j]; |
| 20257 | |
| 20258 | unsigned int expected_result; |
| 20259 | unsigned int result; |
| 20260 | |
| 20261 | if (source2_s >= sizeof(source1_u)) goto skip106; |
| 20262 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 20263 | |
| 20264 | expected_result = (unsigned int) (source1_u >> source2_s); |
| 20265 | |
| 20266 | result = proc(source1_u, source2_s); |
| 20267 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 20268 | if (expected_result != result) { |
| 20269 | printf("Failed unsigned int >> short test, expected %u, got %u, for %u >> %d\n", |
| 20270 | expected_result, result, source1_u, source2_s); |
| 20271 | if (dumped == 0) cod_dump(gen_code); |
| 20272 | failed++; |
| 20273 | dumped++; |
| 20274 | } |
| 20275 | skip106: ; |
| 20276 | } |
| 20277 | } |
| 20278 | if (verbose) printf(" done\n"); |
| 20279 | cod_free_parse_context(context); |
| 20280 | cod_code_free(gen_code); |
| 20281 | } |
| 20282 | if ((only_run_test == NULL((void*)0)) || |
| 20283 | (strcmp(only_run_test, "u>>us") == 0)) { |
| 20284 | int i, j; |
| 20285 | static char code[] = "{\n\ |
| 20286 | unsigned int a = p1;\n\ |
| 20287 | unsigned short b = p2;\n\ |
| 20288 | return a >> b;\n\ |
| 20289 | }"; |
| 20290 | |
| 20291 | unsigned int (*proc)(unsigned int a, unsigned short b); |
| 20292 | cod_parse_context context = new_cod_parse_context(); |
| 20293 | int dumped = 0; |
| 20294 | |
| 20295 | cod_code gen_code; |
| 20296 | |
| 20297 | /* test for unsigned int >> unsigned short */ |
| 20298 | if (verbose) printf("test for unsigned int >> unsigned short"); |
| 20299 | |
| 20300 | cod_assoc_externs(context, externs); |
| 20301 | cod_parse_for_context(extern_string, context); |
| 20302 | |
| 20303 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, unsigned short p2)", |
| 20304 | context); |
| 20305 | gen_code = cod_code_gen(code, context); |
| 20306 | proc = (unsigned int (*)(unsigned int, unsigned short))(long)gen_code->func; |
| 20307 | |
| 20308 | |
| 20309 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 20310 | unsigned int source1_u = src1u_vals[i]; |
| 20311 | for (j=0 ; j < sizeof(sh_src2s_vals)/sizeof(sh_src2s_vals[0]) ; j++) { |
| 20312 | unsigned short source2_us = sh_src2s_vals[j]; |
| 20313 | |
| 20314 | unsigned int expected_result; |
| 20315 | unsigned int result; |
| 20316 | |
| 20317 | if (source2_us >= sizeof(source1_u)) goto skip107; |
| 20318 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 20319 | |
| 20320 | expected_result = (unsigned int) (source1_u >> source2_us); |
| 20321 | |
| 20322 | result = proc(source1_u, source2_us); |
| 20323 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 20324 | if (expected_result != result) { |
| 20325 | printf("Failed unsigned int >> unsigned short test, expected %u, got %u, for %u >> %u\n", |
| 20326 | expected_result, result, source1_u, source2_us); |
| 20327 | if (dumped == 0) cod_dump(gen_code); |
| 20328 | failed++; |
| 20329 | dumped++; |
| 20330 | } |
| 20331 | skip107: ; |
| 20332 | } |
| 20333 | } |
| 20334 | if (verbose) printf(" done\n"); |
| 20335 | cod_free_parse_context(context); |
| 20336 | cod_code_free(gen_code); |
| 20337 | } |
| 20338 | if ((only_run_test == NULL((void*)0)) || |
| 20339 | (strcmp(only_run_test, "u>>i") == 0)) { |
| 20340 | int i, j; |
| 20341 | static char code[] = "{\n\ |
| 20342 | unsigned int a = p1;\n\ |
| 20343 | int b = p2;\n\ |
| 20344 | return a >> b;\n\ |
| 20345 | }"; |
| 20346 | |
| 20347 | unsigned int (*proc)(unsigned int a, int b); |
| 20348 | cod_parse_context context = new_cod_parse_context(); |
| 20349 | int dumped = 0; |
| 20350 | |
| 20351 | cod_code gen_code; |
| 20352 | |
| 20353 | /* test for unsigned int >> int */ |
| 20354 | if (verbose) printf("test for unsigned int >> int"); |
| 20355 | |
| 20356 | cod_assoc_externs(context, externs); |
| 20357 | cod_parse_for_context(extern_string, context); |
| 20358 | |
| 20359 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, int p2)", |
| 20360 | context); |
| 20361 | gen_code = cod_code_gen(code, context); |
| 20362 | proc = (unsigned int (*)(unsigned int, int))(long)gen_code->func; |
| 20363 | |
| 20364 | |
| 20365 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 20366 | unsigned int source1_u = src1u_vals[i]; |
| 20367 | for (j=0 ; j < sizeof(sh_src2_vals)/sizeof(sh_src2_vals[0]) ; j++) { |
| 20368 | int source2_i = sh_src2_vals[j]; |
| 20369 | |
| 20370 | unsigned int expected_result; |
| 20371 | unsigned int result; |
| 20372 | |
| 20373 | if (source2_i >= sizeof(source1_u)) goto skip108; |
| 20374 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 20375 | |
| 20376 | expected_result = (unsigned int) (source1_u >> source2_i); |
| 20377 | |
| 20378 | result = proc(source1_u, source2_i); |
| 20379 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 20380 | if (expected_result != result) { |
| 20381 | printf("Failed unsigned int >> int test, expected %u, got %u, for %u >> %d\n", |
| 20382 | expected_result, result, source1_u, source2_i); |
| 20383 | if (dumped == 0) cod_dump(gen_code); |
| 20384 | failed++; |
| 20385 | dumped++; |
| 20386 | } |
| 20387 | skip108: ; |
| 20388 | } |
| 20389 | } |
| 20390 | if (verbose) printf(" done\n"); |
| 20391 | cod_free_parse_context(context); |
| 20392 | cod_code_free(gen_code); |
| 20393 | } |
| 20394 | if ((only_run_test == NULL((void*)0)) || |
| 20395 | (strcmp(only_run_test, "u>>u") == 0)) { |
| 20396 | int i, j; |
| 20397 | static char code[] = "{\n\ |
| 20398 | unsigned int a = p1;\n\ |
| 20399 | unsigned int b = p2;\n\ |
| 20400 | return a >> b;\n\ |
| 20401 | }"; |
| 20402 | |
| 20403 | unsigned int (*proc)(unsigned int a, unsigned int b); |
| 20404 | cod_parse_context context = new_cod_parse_context(); |
| 20405 | int dumped = 0; |
| 20406 | |
| 20407 | cod_code gen_code; |
| 20408 | |
| 20409 | /* test for unsigned int >> unsigned int */ |
| 20410 | if (verbose) printf("test for unsigned int >> unsigned int"); |
| 20411 | |
| 20412 | cod_assoc_externs(context, externs); |
| 20413 | cod_parse_for_context(extern_string, context); |
| 20414 | |
| 20415 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, unsigned int p2)", |
| 20416 | context); |
| 20417 | gen_code = cod_code_gen(code, context); |
| 20418 | proc = (unsigned int (*)(unsigned int, unsigned int))(long)gen_code->func; |
| 20419 | |
| 20420 | |
| 20421 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 20422 | unsigned int source1_u = src1u_vals[i]; |
| 20423 | for (j=0 ; j < sizeof(sh_src2_vals)/sizeof(sh_src2_vals[0]) ; j++) { |
| 20424 | unsigned int source2_u = sh_src2_vals[j]; |
| 20425 | |
| 20426 | unsigned int expected_result; |
| 20427 | unsigned int result; |
| 20428 | |
| 20429 | if (source2_u >= sizeof(source1_u)) goto skip109; |
| 20430 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 20431 | |
| 20432 | expected_result = (unsigned int) (source1_u >> source2_u); |
| 20433 | |
| 20434 | result = proc(source1_u, source2_u); |
| 20435 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 20436 | if (expected_result != result) { |
| 20437 | printf("Failed unsigned int >> unsigned int test, expected %u, got %u, for %u >> %u\n", |
| 20438 | expected_result, result, source1_u, source2_u); |
| 20439 | if (dumped == 0) cod_dump(gen_code); |
| 20440 | failed++; |
| 20441 | dumped++; |
| 20442 | } |
| 20443 | skip109: ; |
| 20444 | } |
| 20445 | } |
| 20446 | if (verbose) printf(" done\n"); |
| 20447 | cod_free_parse_context(context); |
| 20448 | cod_code_free(gen_code); |
| 20449 | } |
| 20450 | if ((only_run_test == NULL((void*)0)) || |
| 20451 | (strcmp(only_run_test, "u>>ul") == 0)) { |
| 20452 | int i, j; |
| 20453 | static char code[] = "{\n\ |
| 20454 | unsigned int a = p1;\n\ |
| 20455 | unsigned long b = p2;\n\ |
| 20456 | return a >> b;\n\ |
| 20457 | }"; |
| 20458 | |
| 20459 | unsigned int (*proc)(unsigned int a, unsigned long b); |
| 20460 | cod_parse_context context = new_cod_parse_context(); |
| 20461 | int dumped = 0; |
| 20462 | |
| 20463 | cod_code gen_code; |
| 20464 | |
| 20465 | /* test for unsigned int >> unsigned long */ |
| 20466 | if (verbose) printf("test for unsigned int >> unsigned long"); |
| 20467 | |
| 20468 | cod_assoc_externs(context, externs); |
| 20469 | cod_parse_for_context(extern_string, context); |
| 20470 | |
| 20471 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, unsigned long p2)", |
| 20472 | context); |
| 20473 | gen_code = cod_code_gen(code, context); |
| 20474 | proc = (unsigned int (*)(unsigned int, unsigned long))(long)gen_code->func; |
| 20475 | |
| 20476 | |
| 20477 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 20478 | unsigned int source1_u = src1u_vals[i]; |
| 20479 | for (j=0 ; j < sizeof(sh_src2_vals)/sizeof(sh_src2_vals[0]) ; j++) { |
| 20480 | unsigned long source2_ul = sh_src2_vals[j]; |
| 20481 | |
| 20482 | unsigned int expected_result; |
| 20483 | unsigned int result; |
| 20484 | |
| 20485 | if (source2_ul >= sizeof(source1_u)) goto skip110; |
| 20486 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 20487 | |
| 20488 | expected_result = (unsigned int) (source1_u >> source2_ul); |
| 20489 | |
| 20490 | result = proc(source1_u, source2_ul); |
| 20491 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 20492 | if (expected_result != result) { |
| 20493 | printf("Failed unsigned int >> unsigned long test, expected %u, got %u, for %u >> %lu\n", |
| 20494 | expected_result, result, source1_u, source2_ul); |
| 20495 | if (dumped == 0) cod_dump(gen_code); |
| 20496 | failed++; |
| 20497 | dumped++; |
| 20498 | } |
| 20499 | skip110: ; |
| 20500 | } |
| 20501 | } |
| 20502 | if (verbose) printf(" done\n"); |
| 20503 | cod_free_parse_context(context); |
| 20504 | cod_code_free(gen_code); |
| 20505 | } |
| 20506 | if ((only_run_test == NULL((void*)0)) || |
| 20507 | (strcmp(only_run_test, "u>>l") == 0)) { |
| 20508 | int i, j; |
| 20509 | static char code[] = "{\n\ |
| 20510 | unsigned int a = p1;\n\ |
| 20511 | long b = p2;\n\ |
| 20512 | return a >> b;\n\ |
| 20513 | }"; |
| 20514 | |
| 20515 | unsigned int (*proc)(unsigned int a, long b); |
| 20516 | cod_parse_context context = new_cod_parse_context(); |
| 20517 | int dumped = 0; |
| 20518 | |
| 20519 | cod_code gen_code; |
| 20520 | |
| 20521 | /* test for unsigned int >> long */ |
| 20522 | if (verbose) printf("test for unsigned int >> long"); |
| 20523 | |
| 20524 | cod_assoc_externs(context, externs); |
| 20525 | cod_parse_for_context(extern_string, context); |
| 20526 | |
| 20527 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, long p2)", |
| 20528 | context); |
| 20529 | gen_code = cod_code_gen(code, context); |
| 20530 | proc = (unsigned int (*)(unsigned int, long))(long)gen_code->func; |
| 20531 | |
| 20532 | |
| 20533 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 20534 | unsigned int source1_u = src1u_vals[i]; |
| 20535 | for (j=0 ; j < sizeof(sh_src2_vals)/sizeof(sh_src2_vals[0]) ; j++) { |
| 20536 | long source2_l = sh_src2_vals[j]; |
| 20537 | |
| 20538 | unsigned int expected_result; |
| 20539 | unsigned int result; |
| 20540 | |
| 20541 | if (source2_l >= sizeof(source1_u)) goto skip111; |
| 20542 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 20543 | |
| 20544 | expected_result = (unsigned int) (source1_u >> source2_l); |
| 20545 | |
| 20546 | result = proc(source1_u, source2_l); |
| 20547 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 20548 | if (expected_result != result) { |
| 20549 | printf("Failed unsigned int >> long test, expected %u, got %u, for %u >> %ld\n", |
| 20550 | expected_result, result, source1_u, source2_l); |
| 20551 | if (dumped == 0) cod_dump(gen_code); |
| 20552 | failed++; |
| 20553 | dumped++; |
| 20554 | } |
| 20555 | skip111: ; |
| 20556 | } |
| 20557 | } |
| 20558 | if (verbose) printf(" done\n"); |
| 20559 | cod_free_parse_context(context); |
| 20560 | cod_code_free(gen_code); |
| 20561 | } |
| 20562 | } |
| 20563 | void rsh_ul_tests() |
| 20564 | { |
| 20565 | if ((only_run_test == NULL((void*)0)) || |
| 20566 | (strcmp(only_run_test, "ul>>c") == 0)) { |
| 20567 | int i, j; |
| 20568 | static char code[] = "{\n\ |
| 20569 | unsigned long a = p1;\n\ |
| 20570 | signed char b = p2;\n\ |
| 20571 | return a >> b;\n\ |
| 20572 | }"; |
| 20573 | |
| 20574 | unsigned long (*proc)(unsigned long a, signed char b); |
| 20575 | cod_parse_context context = new_cod_parse_context(); |
| 20576 | int dumped = 0; |
| 20577 | |
| 20578 | cod_code gen_code; |
| 20579 | |
| 20580 | /* test for unsigned long >> signed char */ |
| 20581 | if (verbose) printf("test for unsigned long >> signed char"); |
| 20582 | |
| 20583 | cod_assoc_externs(context, externs); |
| 20584 | cod_parse_for_context(extern_string, context); |
| 20585 | |
| 20586 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, signed char p2)", |
| 20587 | context); |
| 20588 | gen_code = cod_code_gen(code, context); |
| 20589 | proc = (unsigned long (*)(unsigned long, signed char))(long)gen_code->func; |
| 20590 | |
| 20591 | |
| 20592 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 20593 | unsigned long source1_ul = src1ul_vals[i]; |
| 20594 | for (j=0 ; j < sizeof(sh_src2c_vals)/sizeof(sh_src2c_vals[0]) ; j++) { |
| 20595 | signed char source2_c = sh_src2c_vals[j]; |
| 20596 | |
| 20597 | unsigned long expected_result; |
| 20598 | unsigned long result; |
| 20599 | |
| 20600 | if (source2_c >= sizeof(source1_ul)) goto skip112; |
| 20601 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 20602 | |
| 20603 | expected_result = (unsigned long) (source1_ul >> source2_c); |
| 20604 | |
| 20605 | result = proc(source1_ul, source2_c); |
| 20606 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 20607 | if (expected_result != result) { |
| 20608 | printf("Failed unsigned long >> signed char test, expected %lu, got %lu, for %lu >> %d\n", |
| 20609 | expected_result, result, source1_ul, source2_c); |
| 20610 | if (dumped == 0) cod_dump(gen_code); |
| 20611 | failed++; |
| 20612 | dumped++; |
| 20613 | } |
| 20614 | skip112: ; |
| 20615 | } |
| 20616 | } |
| 20617 | if (verbose) printf(" done\n"); |
| 20618 | cod_free_parse_context(context); |
| 20619 | cod_code_free(gen_code); |
| 20620 | } |
| 20621 | if ((only_run_test == NULL((void*)0)) || |
| 20622 | (strcmp(only_run_test, "ul>>uc") == 0)) { |
| 20623 | int i, j; |
| 20624 | static char code[] = "{\n\ |
| 20625 | unsigned long a = p1;\n\ |
| 20626 | unsigned char b = p2;\n\ |
| 20627 | return a >> b;\n\ |
| 20628 | }"; |
| 20629 | |
| 20630 | unsigned long (*proc)(unsigned long a, unsigned char b); |
| 20631 | cod_parse_context context = new_cod_parse_context(); |
| 20632 | int dumped = 0; |
| 20633 | |
| 20634 | cod_code gen_code; |
| 20635 | |
| 20636 | /* test for unsigned long >> unsigned char */ |
| 20637 | if (verbose) printf("test for unsigned long >> unsigned char"); |
| 20638 | |
| 20639 | cod_assoc_externs(context, externs); |
| 20640 | cod_parse_for_context(extern_string, context); |
| 20641 | |
| 20642 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, unsigned char p2)", |
| 20643 | context); |
| 20644 | gen_code = cod_code_gen(code, context); |
| 20645 | proc = (unsigned long (*)(unsigned long, unsigned char))(long)gen_code->func; |
| 20646 | |
| 20647 | |
| 20648 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 20649 | unsigned long source1_ul = src1ul_vals[i]; |
| 20650 | for (j=0 ; j < sizeof(sh_src2c_vals)/sizeof(sh_src2c_vals[0]) ; j++) { |
| 20651 | unsigned char source2_uc = sh_src2c_vals[j]; |
| 20652 | |
| 20653 | unsigned long expected_result; |
| 20654 | unsigned long result; |
| 20655 | |
| 20656 | if (source2_uc >= sizeof(source1_ul)) goto skip113; |
| 20657 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 20658 | |
| 20659 | expected_result = (unsigned long) (source1_ul >> source2_uc); |
| 20660 | |
| 20661 | result = proc(source1_ul, source2_uc); |
| 20662 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 20663 | if (expected_result != result) { |
| 20664 | printf("Failed unsigned long >> unsigned char test, expected %lu, got %lu, for %lu >> %u\n", |
| 20665 | expected_result, result, source1_ul, source2_uc); |
| 20666 | if (dumped == 0) cod_dump(gen_code); |
| 20667 | failed++; |
| 20668 | dumped++; |
| 20669 | } |
| 20670 | skip113: ; |
| 20671 | } |
| 20672 | } |
| 20673 | if (verbose) printf(" done\n"); |
| 20674 | cod_free_parse_context(context); |
| 20675 | cod_code_free(gen_code); |
| 20676 | } |
| 20677 | if ((only_run_test == NULL((void*)0)) || |
| 20678 | (strcmp(only_run_test, "ul>>s") == 0)) { |
| 20679 | int i, j; |
| 20680 | static char code[] = "{\n\ |
| 20681 | unsigned long a = p1;\n\ |
| 20682 | short b = p2;\n\ |
| 20683 | return a >> b;\n\ |
| 20684 | }"; |
| 20685 | |
| 20686 | unsigned long (*proc)(unsigned long a, short b); |
| 20687 | cod_parse_context context = new_cod_parse_context(); |
| 20688 | int dumped = 0; |
| 20689 | |
| 20690 | cod_code gen_code; |
| 20691 | |
| 20692 | /* test for unsigned long >> short */ |
| 20693 | if (verbose) printf("test for unsigned long >> short"); |
| 20694 | |
| 20695 | cod_assoc_externs(context, externs); |
| 20696 | cod_parse_for_context(extern_string, context); |
| 20697 | |
| 20698 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, short p2)", |
| 20699 | context); |
| 20700 | gen_code = cod_code_gen(code, context); |
| 20701 | proc = (unsigned long (*)(unsigned long, short))(long)gen_code->func; |
| 20702 | |
| 20703 | |
| 20704 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 20705 | unsigned long source1_ul = src1ul_vals[i]; |
| 20706 | for (j=0 ; j < sizeof(sh_src2s_vals)/sizeof(sh_src2s_vals[0]) ; j++) { |
| 20707 | short source2_s = sh_src2s_vals[j]; |
| 20708 | |
| 20709 | unsigned long expected_result; |
| 20710 | unsigned long result; |
| 20711 | |
| 20712 | if (source2_s >= sizeof(source1_ul)) goto skip114; |
| 20713 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 20714 | |
| 20715 | expected_result = (unsigned long) (source1_ul >> source2_s); |
| 20716 | |
| 20717 | result = proc(source1_ul, source2_s); |
| 20718 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 20719 | if (expected_result != result) { |
| 20720 | printf("Failed unsigned long >> short test, expected %lu, got %lu, for %lu >> %d\n", |
| 20721 | expected_result, result, source1_ul, source2_s); |
| 20722 | if (dumped == 0) cod_dump(gen_code); |
| 20723 | failed++; |
| 20724 | dumped++; |
| 20725 | } |
| 20726 | skip114: ; |
| 20727 | } |
| 20728 | } |
| 20729 | if (verbose) printf(" done\n"); |
| 20730 | cod_free_parse_context(context); |
| 20731 | cod_code_free(gen_code); |
| 20732 | } |
| 20733 | if ((only_run_test == NULL((void*)0)) || |
| 20734 | (strcmp(only_run_test, "ul>>us") == 0)) { |
| 20735 | int i, j; |
| 20736 | static char code[] = "{\n\ |
| 20737 | unsigned long a = p1;\n\ |
| 20738 | unsigned short b = p2;\n\ |
| 20739 | return a >> b;\n\ |
| 20740 | }"; |
| 20741 | |
| 20742 | unsigned long (*proc)(unsigned long a, unsigned short b); |
| 20743 | cod_parse_context context = new_cod_parse_context(); |
| 20744 | int dumped = 0; |
| 20745 | |
| 20746 | cod_code gen_code; |
| 20747 | |
| 20748 | /* test for unsigned long >> unsigned short */ |
| 20749 | if (verbose) printf("test for unsigned long >> unsigned short"); |
| 20750 | |
| 20751 | cod_assoc_externs(context, externs); |
| 20752 | cod_parse_for_context(extern_string, context); |
| 20753 | |
| 20754 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, unsigned short p2)", |
| 20755 | context); |
| 20756 | gen_code = cod_code_gen(code, context); |
| 20757 | proc = (unsigned long (*)(unsigned long, unsigned short))(long)gen_code->func; |
| 20758 | |
| 20759 | |
| 20760 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 20761 | unsigned long source1_ul = src1ul_vals[i]; |
| 20762 | for (j=0 ; j < sizeof(sh_src2s_vals)/sizeof(sh_src2s_vals[0]) ; j++) { |
| 20763 | unsigned short source2_us = sh_src2s_vals[j]; |
| 20764 | |
| 20765 | unsigned long expected_result; |
| 20766 | unsigned long result; |
| 20767 | |
| 20768 | if (source2_us >= sizeof(source1_ul)) goto skip115; |
| 20769 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 20770 | |
| 20771 | expected_result = (unsigned long) (source1_ul >> source2_us); |
| 20772 | |
| 20773 | result = proc(source1_ul, source2_us); |
| 20774 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 20775 | if (expected_result != result) { |
| 20776 | printf("Failed unsigned long >> unsigned short test, expected %lu, got %lu, for %lu >> %u\n", |
| 20777 | expected_result, result, source1_ul, source2_us); |
| 20778 | if (dumped == 0) cod_dump(gen_code); |
| 20779 | failed++; |
| 20780 | dumped++; |
| 20781 | } |
| 20782 | skip115: ; |
| 20783 | } |
| 20784 | } |
| 20785 | if (verbose) printf(" done\n"); |
| 20786 | cod_free_parse_context(context); |
| 20787 | cod_code_free(gen_code); |
| 20788 | } |
| 20789 | if ((only_run_test == NULL((void*)0)) || |
| 20790 | (strcmp(only_run_test, "ul>>i") == 0)) { |
| 20791 | int i, j; |
| 20792 | static char code[] = "{\n\ |
| 20793 | unsigned long a = p1;\n\ |
| 20794 | int b = p2;\n\ |
| 20795 | return a >> b;\n\ |
| 20796 | }"; |
| 20797 | |
| 20798 | unsigned long (*proc)(unsigned long a, int b); |
| 20799 | cod_parse_context context = new_cod_parse_context(); |
| 20800 | int dumped = 0; |
| 20801 | |
| 20802 | cod_code gen_code; |
| 20803 | |
| 20804 | /* test for unsigned long >> int */ |
| 20805 | if (verbose) printf("test for unsigned long >> int"); |
| 20806 | |
| 20807 | cod_assoc_externs(context, externs); |
| 20808 | cod_parse_for_context(extern_string, context); |
| 20809 | |
| 20810 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, int p2)", |
| 20811 | context); |
| 20812 | gen_code = cod_code_gen(code, context); |
| 20813 | proc = (unsigned long (*)(unsigned long, int))(long)gen_code->func; |
| 20814 | |
| 20815 | |
| 20816 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 20817 | unsigned long source1_ul = src1ul_vals[i]; |
| 20818 | for (j=0 ; j < sizeof(sh_src2_vals)/sizeof(sh_src2_vals[0]) ; j++) { |
| 20819 | int source2_i = sh_src2_vals[j]; |
| 20820 | |
| 20821 | unsigned long expected_result; |
| 20822 | unsigned long result; |
| 20823 | |
| 20824 | if (source2_i >= sizeof(source1_ul)) goto skip116; |
| 20825 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 20826 | |
| 20827 | expected_result = (unsigned long) (source1_ul >> source2_i); |
| 20828 | |
| 20829 | result = proc(source1_ul, source2_i); |
| 20830 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 20831 | if (expected_result != result) { |
| 20832 | printf("Failed unsigned long >> int test, expected %lu, got %lu, for %lu >> %d\n", |
| 20833 | expected_result, result, source1_ul, source2_i); |
| 20834 | if (dumped == 0) cod_dump(gen_code); |
| 20835 | failed++; |
| 20836 | dumped++; |
| 20837 | } |
| 20838 | skip116: ; |
| 20839 | } |
| 20840 | } |
| 20841 | if (verbose) printf(" done\n"); |
| 20842 | cod_free_parse_context(context); |
| 20843 | cod_code_free(gen_code); |
| 20844 | } |
| 20845 | if ((only_run_test == NULL((void*)0)) || |
| 20846 | (strcmp(only_run_test, "ul>>u") == 0)) { |
| 20847 | int i, j; |
| 20848 | static char code[] = "{\n\ |
| 20849 | unsigned long a = p1;\n\ |
| 20850 | unsigned int b = p2;\n\ |
| 20851 | return a >> b;\n\ |
| 20852 | }"; |
| 20853 | |
| 20854 | unsigned long (*proc)(unsigned long a, unsigned int b); |
| 20855 | cod_parse_context context = new_cod_parse_context(); |
| 20856 | int dumped = 0; |
| 20857 | |
| 20858 | cod_code gen_code; |
| 20859 | |
| 20860 | /* test for unsigned long >> unsigned int */ |
| 20861 | if (verbose) printf("test for unsigned long >> unsigned int"); |
| 20862 | |
| 20863 | cod_assoc_externs(context, externs); |
| 20864 | cod_parse_for_context(extern_string, context); |
| 20865 | |
| 20866 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, unsigned int p2)", |
| 20867 | context); |
| 20868 | gen_code = cod_code_gen(code, context); |
| 20869 | proc = (unsigned long (*)(unsigned long, unsigned int))(long)gen_code->func; |
| 20870 | |
| 20871 | |
| 20872 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 20873 | unsigned long source1_ul = src1ul_vals[i]; |
| 20874 | for (j=0 ; j < sizeof(sh_src2_vals)/sizeof(sh_src2_vals[0]) ; j++) { |
| 20875 | unsigned int source2_u = sh_src2_vals[j]; |
| 20876 | |
| 20877 | unsigned long expected_result; |
| 20878 | unsigned long result; |
| 20879 | |
| 20880 | if (source2_u >= sizeof(source1_ul)) goto skip117; |
| 20881 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 20882 | |
| 20883 | expected_result = (unsigned long) (source1_ul >> source2_u); |
| 20884 | |
| 20885 | result = proc(source1_ul, source2_u); |
| 20886 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 20887 | if (expected_result != result) { |
| 20888 | printf("Failed unsigned long >> unsigned int test, expected %lu, got %lu, for %lu >> %u\n", |
| 20889 | expected_result, result, source1_ul, source2_u); |
| 20890 | if (dumped == 0) cod_dump(gen_code); |
| 20891 | failed++; |
| 20892 | dumped++; |
| 20893 | } |
| 20894 | skip117: ; |
| 20895 | } |
| 20896 | } |
| 20897 | if (verbose) printf(" done\n"); |
| 20898 | cod_free_parse_context(context); |
| 20899 | cod_code_free(gen_code); |
| 20900 | } |
| 20901 | if ((only_run_test == NULL((void*)0)) || |
| 20902 | (strcmp(only_run_test, "ul>>ul") == 0)) { |
| 20903 | int i, j; |
| 20904 | static char code[] = "{\n\ |
| 20905 | unsigned long a = p1;\n\ |
| 20906 | unsigned long b = p2;\n\ |
| 20907 | return a >> b;\n\ |
| 20908 | }"; |
| 20909 | |
| 20910 | unsigned long (*proc)(unsigned long a, unsigned long b); |
| 20911 | cod_parse_context context = new_cod_parse_context(); |
| 20912 | int dumped = 0; |
| 20913 | |
| 20914 | cod_code gen_code; |
| 20915 | |
| 20916 | /* test for unsigned long >> unsigned long */ |
| 20917 | if (verbose) printf("test for unsigned long >> unsigned long"); |
| 20918 | |
| 20919 | cod_assoc_externs(context, externs); |
| 20920 | cod_parse_for_context(extern_string, context); |
| 20921 | |
| 20922 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, unsigned long p2)", |
| 20923 | context); |
| 20924 | gen_code = cod_code_gen(code, context); |
| 20925 | proc = (unsigned long (*)(unsigned long, unsigned long))(long)gen_code->func; |
| 20926 | |
| 20927 | |
| 20928 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 20929 | unsigned long source1_ul = src1ul_vals[i]; |
| 20930 | for (j=0 ; j < sizeof(sh_src2_vals)/sizeof(sh_src2_vals[0]) ; j++) { |
| 20931 | unsigned long source2_ul = sh_src2_vals[j]; |
| 20932 | |
| 20933 | unsigned long expected_result; |
| 20934 | unsigned long result; |
| 20935 | |
| 20936 | if (source2_ul >= sizeof(source1_ul)) goto skip118; |
| 20937 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 20938 | |
| 20939 | expected_result = (unsigned long) (source1_ul >> source2_ul); |
| 20940 | |
| 20941 | result = proc(source1_ul, source2_ul); |
| 20942 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 20943 | if (expected_result != result) { |
| 20944 | printf("Failed unsigned long >> unsigned long test, expected %lu, got %lu, for %lu >> %lu\n", |
| 20945 | expected_result, result, source1_ul, source2_ul); |
| 20946 | if (dumped == 0) cod_dump(gen_code); |
| 20947 | failed++; |
| 20948 | dumped++; |
| 20949 | } |
| 20950 | skip118: ; |
| 20951 | } |
| 20952 | } |
| 20953 | if (verbose) printf(" done\n"); |
| 20954 | cod_free_parse_context(context); |
| 20955 | cod_code_free(gen_code); |
| 20956 | } |
| 20957 | if ((only_run_test == NULL((void*)0)) || |
| 20958 | (strcmp(only_run_test, "ul>>l") == 0)) { |
| 20959 | int i, j; |
| 20960 | static char code[] = "{\n\ |
| 20961 | unsigned long a = p1;\n\ |
| 20962 | long b = p2;\n\ |
| 20963 | return a >> b;\n\ |
| 20964 | }"; |
| 20965 | |
| 20966 | unsigned long (*proc)(unsigned long a, long b); |
| 20967 | cod_parse_context context = new_cod_parse_context(); |
| 20968 | int dumped = 0; |
| 20969 | |
| 20970 | cod_code gen_code; |
| 20971 | |
| 20972 | /* test for unsigned long >> long */ |
| 20973 | if (verbose) printf("test for unsigned long >> long"); |
| 20974 | |
| 20975 | cod_assoc_externs(context, externs); |
| 20976 | cod_parse_for_context(extern_string, context); |
| 20977 | |
| 20978 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, long p2)", |
| 20979 | context); |
| 20980 | gen_code = cod_code_gen(code, context); |
| 20981 | proc = (unsigned long (*)(unsigned long, long))(long)gen_code->func; |
| 20982 | |
| 20983 | |
| 20984 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 20985 | unsigned long source1_ul = src1ul_vals[i]; |
| 20986 | for (j=0 ; j < sizeof(sh_src2_vals)/sizeof(sh_src2_vals[0]) ; j++) { |
| 20987 | long source2_l = sh_src2_vals[j]; |
| 20988 | |
| 20989 | unsigned long expected_result; |
| 20990 | unsigned long result; |
| 20991 | |
| 20992 | if (source2_l >= sizeof(source1_ul)) goto skip119; |
| 20993 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 20994 | |
| 20995 | expected_result = (unsigned long) (source1_ul >> source2_l); |
| 20996 | |
| 20997 | result = proc(source1_ul, source2_l); |
| 20998 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 20999 | if (expected_result != result) { |
| 21000 | printf("Failed unsigned long >> long test, expected %lu, got %lu, for %lu >> %ld\n", |
| 21001 | expected_result, result, source1_ul, source2_l); |
| 21002 | if (dumped == 0) cod_dump(gen_code); |
| 21003 | failed++; |
| 21004 | dumped++; |
| 21005 | } |
| 21006 | skip119: ; |
| 21007 | } |
| 21008 | } |
| 21009 | if (verbose) printf(" done\n"); |
| 21010 | cod_free_parse_context(context); |
| 21011 | cod_code_free(gen_code); |
| 21012 | } |
| 21013 | } |
| 21014 | void rsh_l_tests() |
| 21015 | { |
| 21016 | if ((only_run_test == NULL((void*)0)) || |
| 21017 | (strcmp(only_run_test, "l>>c") == 0)) { |
| 21018 | int i, j; |
| 21019 | static char code[] = "{\n\ |
| 21020 | long a = p1;\n\ |
| 21021 | signed char b = p2;\n\ |
| 21022 | return a >> b;\n\ |
| 21023 | }"; |
| 21024 | |
| 21025 | long (*proc)(long a, signed char b); |
| 21026 | cod_parse_context context = new_cod_parse_context(); |
| 21027 | int dumped = 0; |
| 21028 | |
| 21029 | cod_code gen_code; |
| 21030 | |
| 21031 | /* test for long >> signed char */ |
| 21032 | if (verbose) printf("test for long >> signed char"); |
| 21033 | |
| 21034 | cod_assoc_externs(context, externs); |
| 21035 | cod_parse_for_context(extern_string, context); |
| 21036 | |
| 21037 | cod_subroutine_declaration("long proc(long p1, signed char p2)", |
| 21038 | context); |
| 21039 | gen_code = cod_code_gen(code, context); |
| 21040 | proc = (long (*)(long, signed char))(long)gen_code->func; |
| 21041 | |
| 21042 | |
| 21043 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 21044 | long source1_l = src1l_vals[i]; |
| 21045 | for (j=0 ; j < sizeof(sh_src2c_vals)/sizeof(sh_src2c_vals[0]) ; j++) { |
| 21046 | signed char source2_c = sh_src2c_vals[j]; |
| 21047 | |
| 21048 | long expected_result; |
| 21049 | long result; |
| 21050 | |
| 21051 | if (source2_c >= sizeof(source1_l)) goto skip120; |
| 21052 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 21053 | |
| 21054 | expected_result = (long) (source1_l >> source2_c); |
| 21055 | |
| 21056 | result = proc(source1_l, source2_c); |
| 21057 | if (expected_result != result) { |
| 21058 | printf("Failed long >> signed char test, expected %ld, got %ld, for %ld >> %d\n", |
| 21059 | expected_result, result, source1_l, source2_c); |
| 21060 | if (dumped == 0) cod_dump(gen_code); |
| 21061 | failed++; |
| 21062 | dumped++; |
| 21063 | } |
| 21064 | skip120: ; |
| 21065 | } |
| 21066 | } |
| 21067 | if (verbose) printf(" done\n"); |
| 21068 | cod_free_parse_context(context); |
| 21069 | cod_code_free(gen_code); |
| 21070 | } |
| 21071 | if ((only_run_test == NULL((void*)0)) || |
| 21072 | (strcmp(only_run_test, "l>>uc") == 0)) { |
| 21073 | int i, j; |
| 21074 | static char code[] = "{\n\ |
| 21075 | long a = p1;\n\ |
| 21076 | unsigned char b = p2;\n\ |
| 21077 | return a >> b;\n\ |
| 21078 | }"; |
| 21079 | |
| 21080 | long (*proc)(long a, unsigned char b); |
| 21081 | cod_parse_context context = new_cod_parse_context(); |
| 21082 | int dumped = 0; |
| 21083 | |
| 21084 | cod_code gen_code; |
| 21085 | |
| 21086 | /* test for long >> unsigned char */ |
| 21087 | if (verbose) printf("test for long >> unsigned char"); |
| 21088 | |
| 21089 | cod_assoc_externs(context, externs); |
| 21090 | cod_parse_for_context(extern_string, context); |
| 21091 | |
| 21092 | cod_subroutine_declaration("long proc(long p1, unsigned char p2)", |
| 21093 | context); |
| 21094 | gen_code = cod_code_gen(code, context); |
| 21095 | proc = (long (*)(long, unsigned char))(long)gen_code->func; |
| 21096 | |
| 21097 | |
| 21098 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 21099 | long source1_l = src1l_vals[i]; |
| 21100 | for (j=0 ; j < sizeof(sh_src2c_vals)/sizeof(sh_src2c_vals[0]) ; j++) { |
| 21101 | unsigned char source2_uc = sh_src2c_vals[j]; |
| 21102 | |
| 21103 | long expected_result; |
| 21104 | long result; |
| 21105 | |
| 21106 | if (source2_uc >= sizeof(source1_l)) goto skip121; |
| 21107 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 21108 | |
| 21109 | expected_result = (long) (source1_l >> source2_uc); |
| 21110 | |
| 21111 | result = proc(source1_l, source2_uc); |
| 21112 | if (expected_result != result) { |
| 21113 | printf("Failed long >> unsigned char test, expected %ld, got %ld, for %ld >> %u\n", |
| 21114 | expected_result, result, source1_l, source2_uc); |
| 21115 | if (dumped == 0) cod_dump(gen_code); |
| 21116 | failed++; |
| 21117 | dumped++; |
| 21118 | } |
| 21119 | skip121: ; |
| 21120 | } |
| 21121 | } |
| 21122 | if (verbose) printf(" done\n"); |
| 21123 | cod_free_parse_context(context); |
| 21124 | cod_code_free(gen_code); |
| 21125 | } |
| 21126 | if ((only_run_test == NULL((void*)0)) || |
| 21127 | (strcmp(only_run_test, "l>>s") == 0)) { |
| 21128 | int i, j; |
| 21129 | static char code[] = "{\n\ |
| 21130 | long a = p1;\n\ |
| 21131 | short b = p2;\n\ |
| 21132 | return a >> b;\n\ |
| 21133 | }"; |
| 21134 | |
| 21135 | long (*proc)(long a, short b); |
| 21136 | cod_parse_context context = new_cod_parse_context(); |
| 21137 | int dumped = 0; |
| 21138 | |
| 21139 | cod_code gen_code; |
| 21140 | |
| 21141 | /* test for long >> short */ |
| 21142 | if (verbose) printf("test for long >> short"); |
| 21143 | |
| 21144 | cod_assoc_externs(context, externs); |
| 21145 | cod_parse_for_context(extern_string, context); |
| 21146 | |
| 21147 | cod_subroutine_declaration("long proc(long p1, short p2)", |
| 21148 | context); |
| 21149 | gen_code = cod_code_gen(code, context); |
| 21150 | proc = (long (*)(long, short))(long)gen_code->func; |
| 21151 | |
| 21152 | |
| 21153 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 21154 | long source1_l = src1l_vals[i]; |
| 21155 | for (j=0 ; j < sizeof(sh_src2s_vals)/sizeof(sh_src2s_vals[0]) ; j++) { |
| 21156 | short source2_s = sh_src2s_vals[j]; |
| 21157 | |
| 21158 | long expected_result; |
| 21159 | long result; |
| 21160 | |
| 21161 | if (source2_s >= sizeof(source1_l)) goto skip122; |
| 21162 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 21163 | |
| 21164 | expected_result = (long) (source1_l >> source2_s); |
| 21165 | |
| 21166 | result = proc(source1_l, source2_s); |
| 21167 | if (expected_result != result) { |
| 21168 | printf("Failed long >> short test, expected %ld, got %ld, for %ld >> %d\n", |
| 21169 | expected_result, result, source1_l, source2_s); |
| 21170 | if (dumped == 0) cod_dump(gen_code); |
| 21171 | failed++; |
| 21172 | dumped++; |
| 21173 | } |
| 21174 | skip122: ; |
| 21175 | } |
| 21176 | } |
| 21177 | if (verbose) printf(" done\n"); |
| 21178 | cod_free_parse_context(context); |
| 21179 | cod_code_free(gen_code); |
| 21180 | } |
| 21181 | if ((only_run_test == NULL((void*)0)) || |
| 21182 | (strcmp(only_run_test, "l>>us") == 0)) { |
| 21183 | int i, j; |
| 21184 | static char code[] = "{\n\ |
| 21185 | long a = p1;\n\ |
| 21186 | unsigned short b = p2;\n\ |
| 21187 | return a >> b;\n\ |
| 21188 | }"; |
| 21189 | |
| 21190 | long (*proc)(long a, unsigned short b); |
| 21191 | cod_parse_context context = new_cod_parse_context(); |
| 21192 | int dumped = 0; |
| 21193 | |
| 21194 | cod_code gen_code; |
| 21195 | |
| 21196 | /* test for long >> unsigned short */ |
| 21197 | if (verbose) printf("test for long >> unsigned short"); |
| 21198 | |
| 21199 | cod_assoc_externs(context, externs); |
| 21200 | cod_parse_for_context(extern_string, context); |
| 21201 | |
| 21202 | cod_subroutine_declaration("long proc(long p1, unsigned short p2)", |
| 21203 | context); |
| 21204 | gen_code = cod_code_gen(code, context); |
| 21205 | proc = (long (*)(long, unsigned short))(long)gen_code->func; |
| 21206 | |
| 21207 | |
| 21208 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 21209 | long source1_l = src1l_vals[i]; |
| 21210 | for (j=0 ; j < sizeof(sh_src2s_vals)/sizeof(sh_src2s_vals[0]) ; j++) { |
| 21211 | unsigned short source2_us = sh_src2s_vals[j]; |
| 21212 | |
| 21213 | long expected_result; |
| 21214 | long result; |
| 21215 | |
| 21216 | if (source2_us >= sizeof(source1_l)) goto skip123; |
| 21217 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 21218 | |
| 21219 | expected_result = (long) (source1_l >> source2_us); |
| 21220 | |
| 21221 | result = proc(source1_l, source2_us); |
| 21222 | if (expected_result != result) { |
| 21223 | printf("Failed long >> unsigned short test, expected %ld, got %ld, for %ld >> %u\n", |
| 21224 | expected_result, result, source1_l, source2_us); |
| 21225 | if (dumped == 0) cod_dump(gen_code); |
| 21226 | failed++; |
| 21227 | dumped++; |
| 21228 | } |
| 21229 | skip123: ; |
| 21230 | } |
| 21231 | } |
| 21232 | if (verbose) printf(" done\n"); |
| 21233 | cod_free_parse_context(context); |
| 21234 | cod_code_free(gen_code); |
| 21235 | } |
| 21236 | if ((only_run_test == NULL((void*)0)) || |
| 21237 | (strcmp(only_run_test, "l>>i") == 0)) { |
| 21238 | int i, j; |
| 21239 | static char code[] = "{\n\ |
| 21240 | long a = p1;\n\ |
| 21241 | int b = p2;\n\ |
| 21242 | return a >> b;\n\ |
| 21243 | }"; |
| 21244 | |
| 21245 | long (*proc)(long a, int b); |
| 21246 | cod_parse_context context = new_cod_parse_context(); |
| 21247 | int dumped = 0; |
| 21248 | |
| 21249 | cod_code gen_code; |
| 21250 | |
| 21251 | /* test for long >> int */ |
| 21252 | if (verbose) printf("test for long >> int"); |
| 21253 | |
| 21254 | cod_assoc_externs(context, externs); |
| 21255 | cod_parse_for_context(extern_string, context); |
| 21256 | |
| 21257 | cod_subroutine_declaration("long proc(long p1, int p2)", |
| 21258 | context); |
| 21259 | gen_code = cod_code_gen(code, context); |
| 21260 | proc = (long (*)(long, int))(long)gen_code->func; |
| 21261 | |
| 21262 | |
| 21263 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 21264 | long source1_l = src1l_vals[i]; |
| 21265 | for (j=0 ; j < sizeof(sh_src2_vals)/sizeof(sh_src2_vals[0]) ; j++) { |
| 21266 | int source2_i = sh_src2_vals[j]; |
| 21267 | |
| 21268 | long expected_result; |
| 21269 | long result; |
| 21270 | |
| 21271 | if (source2_i >= sizeof(source1_l)) goto skip124; |
| 21272 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 21273 | |
| 21274 | expected_result = (long) (source1_l >> source2_i); |
| 21275 | |
| 21276 | result = proc(source1_l, source2_i); |
| 21277 | if (expected_result != result) { |
| 21278 | printf("Failed long >> int test, expected %ld, got %ld, for %ld >> %d\n", |
| 21279 | expected_result, result, source1_l, source2_i); |
| 21280 | if (dumped == 0) cod_dump(gen_code); |
| 21281 | failed++; |
| 21282 | dumped++; |
| 21283 | } |
| 21284 | skip124: ; |
| 21285 | } |
| 21286 | } |
| 21287 | if (verbose) printf(" done\n"); |
| 21288 | cod_free_parse_context(context); |
| 21289 | cod_code_free(gen_code); |
| 21290 | } |
| 21291 | if ((only_run_test == NULL((void*)0)) || |
| 21292 | (strcmp(only_run_test, "l>>u") == 0)) { |
| 21293 | int i, j; |
| 21294 | static char code[] = "{\n\ |
| 21295 | long a = p1;\n\ |
| 21296 | unsigned int b = p2;\n\ |
| 21297 | return a >> b;\n\ |
| 21298 | }"; |
| 21299 | |
| 21300 | long (*proc)(long a, unsigned int b); |
| 21301 | cod_parse_context context = new_cod_parse_context(); |
| 21302 | int dumped = 0; |
| 21303 | |
| 21304 | cod_code gen_code; |
| 21305 | |
| 21306 | /* test for long >> unsigned int */ |
| 21307 | if (verbose) printf("test for long >> unsigned int"); |
| 21308 | |
| 21309 | cod_assoc_externs(context, externs); |
| 21310 | cod_parse_for_context(extern_string, context); |
| 21311 | |
| 21312 | cod_subroutine_declaration("long proc(long p1, unsigned int p2)", |
| 21313 | context); |
| 21314 | gen_code = cod_code_gen(code, context); |
| 21315 | proc = (long (*)(long, unsigned int))(long)gen_code->func; |
| 21316 | |
| 21317 | |
| 21318 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 21319 | long source1_l = src1l_vals[i]; |
| 21320 | for (j=0 ; j < sizeof(sh_src2_vals)/sizeof(sh_src2_vals[0]) ; j++) { |
| 21321 | unsigned int source2_u = sh_src2_vals[j]; |
| 21322 | |
| 21323 | long expected_result; |
| 21324 | long result; |
| 21325 | |
| 21326 | if (source2_u >= sizeof(source1_l)) goto skip125; |
| 21327 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 21328 | |
| 21329 | expected_result = (long) (source1_l >> source2_u); |
| 21330 | |
| 21331 | result = proc(source1_l, source2_u); |
| 21332 | if (expected_result != result) { |
| 21333 | printf("Failed long >> unsigned int test, expected %ld, got %ld, for %ld >> %u\n", |
| 21334 | expected_result, result, source1_l, source2_u); |
| 21335 | if (dumped == 0) cod_dump(gen_code); |
| 21336 | failed++; |
| 21337 | dumped++; |
| 21338 | } |
| 21339 | skip125: ; |
| 21340 | } |
| 21341 | } |
| 21342 | if (verbose) printf(" done\n"); |
| 21343 | cod_free_parse_context(context); |
| 21344 | cod_code_free(gen_code); |
| 21345 | } |
| 21346 | if ((only_run_test == NULL((void*)0)) || |
| 21347 | (strcmp(only_run_test, "l>>ul") == 0)) { |
| 21348 | int i, j; |
| 21349 | static char code[] = "{\n\ |
| 21350 | long a = p1;\n\ |
| 21351 | unsigned long b = p2;\n\ |
| 21352 | return a >> b;\n\ |
| 21353 | }"; |
| 21354 | |
| 21355 | long (*proc)(long a, unsigned long b); |
| 21356 | cod_parse_context context = new_cod_parse_context(); |
| 21357 | int dumped = 0; |
| 21358 | |
| 21359 | cod_code gen_code; |
| 21360 | |
| 21361 | /* test for long >> unsigned long */ |
| 21362 | if (verbose) printf("test for long >> unsigned long"); |
| 21363 | |
| 21364 | cod_assoc_externs(context, externs); |
| 21365 | cod_parse_for_context(extern_string, context); |
| 21366 | |
| 21367 | cod_subroutine_declaration("long proc(long p1, unsigned long p2)", |
| 21368 | context); |
| 21369 | gen_code = cod_code_gen(code, context); |
| 21370 | proc = (long (*)(long, unsigned long))(long)gen_code->func; |
| 21371 | |
| 21372 | |
| 21373 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 21374 | long source1_l = src1l_vals[i]; |
| 21375 | for (j=0 ; j < sizeof(sh_src2_vals)/sizeof(sh_src2_vals[0]) ; j++) { |
| 21376 | unsigned long source2_ul = sh_src2_vals[j]; |
| 21377 | |
| 21378 | long expected_result; |
| 21379 | long result; |
| 21380 | |
| 21381 | if (source2_ul >= sizeof(source1_l)) goto skip126; |
| 21382 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 21383 | |
| 21384 | expected_result = (long) (source1_l >> source2_ul); |
| 21385 | |
| 21386 | result = proc(source1_l, source2_ul); |
| 21387 | if (expected_result != result) { |
| 21388 | printf("Failed long >> unsigned long test, expected %ld, got %ld, for %ld >> %lu\n", |
| 21389 | expected_result, result, source1_l, source2_ul); |
| 21390 | if (dumped == 0) cod_dump(gen_code); |
| 21391 | failed++; |
| 21392 | dumped++; |
| 21393 | } |
| 21394 | skip126: ; |
| 21395 | } |
| 21396 | } |
| 21397 | if (verbose) printf(" done\n"); |
| 21398 | cod_free_parse_context(context); |
| 21399 | cod_code_free(gen_code); |
| 21400 | } |
| 21401 | if ((only_run_test == NULL((void*)0)) || |
| 21402 | (strcmp(only_run_test, "l>>l") == 0)) { |
| 21403 | int i, j; |
| 21404 | static char code[] = "{\n\ |
| 21405 | long a = p1;\n\ |
| 21406 | long b = p2;\n\ |
| 21407 | return a >> b;\n\ |
| 21408 | }"; |
| 21409 | |
| 21410 | long (*proc)(long a, long b); |
| 21411 | cod_parse_context context = new_cod_parse_context(); |
| 21412 | int dumped = 0; |
| 21413 | |
| 21414 | cod_code gen_code; |
| 21415 | |
| 21416 | /* test for long >> long */ |
| 21417 | if (verbose) printf("test for long >> long"); |
| 21418 | |
| 21419 | cod_assoc_externs(context, externs); |
| 21420 | cod_parse_for_context(extern_string, context); |
| 21421 | |
| 21422 | cod_subroutine_declaration("long proc(long p1, long p2)", |
| 21423 | context); |
| 21424 | gen_code = cod_code_gen(code, context); |
| 21425 | proc = (long (*)(long, long))(long)gen_code->func; |
| 21426 | |
| 21427 | |
| 21428 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 21429 | long source1_l = src1l_vals[i]; |
| 21430 | for (j=0 ; j < sizeof(sh_src2_vals)/sizeof(sh_src2_vals[0]) ; j++) { |
| 21431 | long source2_l = sh_src2_vals[j]; |
| 21432 | |
| 21433 | long expected_result; |
| 21434 | long result; |
| 21435 | |
| 21436 | if (source2_l >= sizeof(source1_l)) goto skip127; |
| 21437 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 21438 | |
| 21439 | expected_result = (long) (source1_l >> source2_l); |
| 21440 | |
| 21441 | result = proc(source1_l, source2_l); |
| 21442 | if (expected_result != result) { |
| 21443 | printf("Failed long >> long test, expected %ld, got %ld, for %ld >> %ld\n", |
| 21444 | expected_result, result, source1_l, source2_l); |
| 21445 | if (dumped == 0) cod_dump(gen_code); |
| 21446 | failed++; |
| 21447 | dumped++; |
| 21448 | } |
| 21449 | skip127: ; |
| 21450 | } |
| 21451 | } |
| 21452 | if (verbose) printf(" done\n"); |
| 21453 | cod_free_parse_context(context); |
| 21454 | cod_code_free(gen_code); |
| 21455 | } |
| 21456 | } |
| 21457 | void add_c_tests() |
| 21458 | { |
| 21459 | if ((only_run_test == NULL((void*)0)) || |
| 21460 | (strcmp(only_run_test, "c+c") == 0)) { |
| 21461 | int i, j; |
| 21462 | static char code[] = "{\n\ |
| 21463 | signed char a = p1;\n\ |
| 21464 | signed char b = p2;\n\ |
| 21465 | return a + b;\n\ |
| 21466 | }"; |
| 21467 | |
| 21468 | signed char (*proc)(signed char a, signed char b); |
| 21469 | cod_parse_context context = new_cod_parse_context(); |
| 21470 | int dumped = 0; |
| 21471 | |
| 21472 | cod_code gen_code; |
| 21473 | |
| 21474 | /* test for signed char + signed char */ |
| 21475 | if (verbose) printf("test for signed char + signed char"); |
| 21476 | |
| 21477 | cod_assoc_externs(context, externs); |
| 21478 | cod_parse_for_context(extern_string, context); |
| 21479 | |
| 21480 | cod_subroutine_declaration("signed char proc(signed char p1, signed char p2)", |
| 21481 | context); |
| 21482 | gen_code = cod_code_gen(code, context); |
| 21483 | proc = (signed char (*)(signed char, signed char))(long)gen_code->func; |
| 21484 | |
| 21485 | |
| 21486 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 21487 | signed char source1_c = src1c_vals[i]; |
| 21488 | for (j=0 ; j < sizeof(src2c_vals)/sizeof(src2c_vals[0]) ; j++) { |
| 21489 | signed char source2_c = src2c_vals[j]; |
| 21490 | |
| 21491 | signed char expected_result; |
| 21492 | signed char result; |
| 21493 | |
| 21494 | |
| 21495 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 21496 | |
| 21497 | expected_result = (signed char) (source1_c + source2_c); |
| 21498 | |
| 21499 | result = proc(source1_c, source2_c); |
| 21500 | if (expected_result != result) { |
| 21501 | printf("Failed signed char + signed char test, expected %d, got %d, for %d + %d\n", |
| 21502 | expected_result, result, source1_c, source2_c); |
| 21503 | if (dumped == 0) cod_dump(gen_code); |
| 21504 | failed++; |
| 21505 | dumped++; |
| 21506 | } |
| 21507 | } |
| 21508 | } |
| 21509 | if (verbose) printf(" done\n"); |
| 21510 | cod_free_parse_context(context); |
| 21511 | cod_code_free(gen_code); |
| 21512 | } |
| 21513 | if ((only_run_test == NULL((void*)0)) || |
| 21514 | (strcmp(only_run_test, "c+uc") == 0)) { |
| 21515 | int i, j; |
| 21516 | static char code[] = "{\n\ |
| 21517 | signed char a = p1;\n\ |
| 21518 | unsigned char b = p2;\n\ |
| 21519 | return a + b;\n\ |
| 21520 | }"; |
| 21521 | |
| 21522 | signed char (*proc)(signed char a, unsigned char b); |
| 21523 | cod_parse_context context = new_cod_parse_context(); |
| 21524 | int dumped = 0; |
| 21525 | |
| 21526 | cod_code gen_code; |
| 21527 | |
| 21528 | /* test for signed char + unsigned char */ |
| 21529 | if (verbose) printf("test for signed char + unsigned char"); |
| 21530 | |
| 21531 | cod_assoc_externs(context, externs); |
| 21532 | cod_parse_for_context(extern_string, context); |
| 21533 | |
| 21534 | cod_subroutine_declaration("signed char proc(signed char p1, unsigned char p2)", |
| 21535 | context); |
| 21536 | gen_code = cod_code_gen(code, context); |
| 21537 | proc = (signed char (*)(signed char, unsigned char))(long)gen_code->func; |
| 21538 | |
| 21539 | |
| 21540 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 21541 | signed char source1_c = src1c_vals[i]; |
| 21542 | for (j=0 ; j < sizeof(src2uc_vals)/sizeof(src2uc_vals[0]) ; j++) { |
| 21543 | unsigned char source2_uc = src2uc_vals[j]; |
| 21544 | |
| 21545 | signed char expected_result; |
| 21546 | signed char result; |
| 21547 | |
| 21548 | |
| 21549 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 21550 | |
| 21551 | expected_result = (signed char) (source1_c + source2_uc); |
| 21552 | |
| 21553 | result = proc(source1_c, source2_uc); |
| 21554 | if (expected_result != result) { |
| 21555 | printf("Failed signed char + unsigned char test, expected %d, got %d, for %d + %u\n", |
| 21556 | expected_result, result, source1_c, source2_uc); |
| 21557 | if (dumped == 0) cod_dump(gen_code); |
| 21558 | failed++; |
| 21559 | dumped++; |
| 21560 | } |
| 21561 | } |
| 21562 | } |
| 21563 | if (verbose) printf(" done\n"); |
| 21564 | cod_free_parse_context(context); |
| 21565 | cod_code_free(gen_code); |
| 21566 | } |
| 21567 | if ((only_run_test == NULL((void*)0)) || |
| 21568 | (strcmp(only_run_test, "c+s") == 0)) { |
| 21569 | int i, j; |
| 21570 | static char code[] = "{\n\ |
| 21571 | signed char a = p1;\n\ |
| 21572 | short b = p2;\n\ |
| 21573 | return a + b;\n\ |
| 21574 | }"; |
| 21575 | |
| 21576 | signed char (*proc)(signed char a, short b); |
| 21577 | cod_parse_context context = new_cod_parse_context(); |
| 21578 | int dumped = 0; |
| 21579 | |
| 21580 | cod_code gen_code; |
| 21581 | |
| 21582 | /* test for signed char + short */ |
| 21583 | if (verbose) printf("test for signed char + short"); |
| 21584 | |
| 21585 | cod_assoc_externs(context, externs); |
| 21586 | cod_parse_for_context(extern_string, context); |
| 21587 | |
| 21588 | cod_subroutine_declaration("signed char proc(signed char p1, short p2)", |
| 21589 | context); |
| 21590 | gen_code = cod_code_gen(code, context); |
| 21591 | proc = (signed char (*)(signed char, short))(long)gen_code->func; |
| 21592 | |
| 21593 | |
| 21594 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 21595 | signed char source1_c = src1c_vals[i]; |
| 21596 | for (j=0 ; j < sizeof(src2s_vals)/sizeof(src2s_vals[0]) ; j++) { |
| 21597 | short source2_s = src2s_vals[j]; |
| 21598 | |
| 21599 | signed char expected_result; |
| 21600 | signed char result; |
| 21601 | |
| 21602 | |
| 21603 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 21604 | |
| 21605 | expected_result = (signed char) (source1_c + source2_s); |
| 21606 | |
| 21607 | result = proc(source1_c, source2_s); |
| 21608 | if (expected_result != result) { |
| 21609 | printf("Failed signed char + short test, expected %d, got %d, for %d + %d\n", |
| 21610 | expected_result, result, source1_c, source2_s); |
| 21611 | if (dumped == 0) cod_dump(gen_code); |
| 21612 | failed++; |
| 21613 | dumped++; |
| 21614 | } |
| 21615 | } |
| 21616 | } |
| 21617 | if (verbose) printf(" done\n"); |
| 21618 | cod_free_parse_context(context); |
| 21619 | cod_code_free(gen_code); |
| 21620 | } |
| 21621 | if ((only_run_test == NULL((void*)0)) || |
| 21622 | (strcmp(only_run_test, "c+us") == 0)) { |
| 21623 | int i, j; |
| 21624 | static char code[] = "{\n\ |
| 21625 | signed char a = p1;\n\ |
| 21626 | unsigned short b = p2;\n\ |
| 21627 | return a + b;\n\ |
| 21628 | }"; |
| 21629 | |
| 21630 | signed char (*proc)(signed char a, unsigned short b); |
| 21631 | cod_parse_context context = new_cod_parse_context(); |
| 21632 | int dumped = 0; |
| 21633 | |
| 21634 | cod_code gen_code; |
| 21635 | |
| 21636 | /* test for signed char + unsigned short */ |
| 21637 | if (verbose) printf("test for signed char + unsigned short"); |
| 21638 | |
| 21639 | cod_assoc_externs(context, externs); |
| 21640 | cod_parse_for_context(extern_string, context); |
| 21641 | |
| 21642 | cod_subroutine_declaration("signed char proc(signed char p1, unsigned short p2)", |
| 21643 | context); |
| 21644 | gen_code = cod_code_gen(code, context); |
| 21645 | proc = (signed char (*)(signed char, unsigned short))(long)gen_code->func; |
| 21646 | |
| 21647 | |
| 21648 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 21649 | signed char source1_c = src1c_vals[i]; |
| 21650 | for (j=0 ; j < sizeof(src2us_vals)/sizeof(src2us_vals[0]) ; j++) { |
| 21651 | unsigned short source2_us = src2us_vals[j]; |
| 21652 | |
| 21653 | signed char expected_result; |
| 21654 | signed char result; |
| 21655 | |
| 21656 | |
| 21657 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 21658 | |
| 21659 | expected_result = (signed char) (source1_c + source2_us); |
| 21660 | |
| 21661 | result = proc(source1_c, source2_us); |
| 21662 | if (expected_result != result) { |
| 21663 | printf("Failed signed char + unsigned short test, expected %d, got %d, for %d + %u\n", |
| 21664 | expected_result, result, source1_c, source2_us); |
| 21665 | if (dumped == 0) cod_dump(gen_code); |
| 21666 | failed++; |
| 21667 | dumped++; |
| 21668 | } |
| 21669 | } |
| 21670 | } |
| 21671 | if (verbose) printf(" done\n"); |
| 21672 | cod_free_parse_context(context); |
| 21673 | cod_code_free(gen_code); |
| 21674 | } |
| 21675 | if ((only_run_test == NULL((void*)0)) || |
| 21676 | (strcmp(only_run_test, "c+i") == 0)) { |
| 21677 | int i, j; |
| 21678 | static char code[] = "{\n\ |
| 21679 | signed char a = p1;\n\ |
| 21680 | int b = p2;\n\ |
| 21681 | return a + b;\n\ |
| 21682 | }"; |
| 21683 | |
| 21684 | signed char (*proc)(signed char a, int b); |
| 21685 | cod_parse_context context = new_cod_parse_context(); |
| 21686 | int dumped = 0; |
| 21687 | |
| 21688 | cod_code gen_code; |
| 21689 | |
| 21690 | /* test for signed char + int */ |
| 21691 | if (verbose) printf("test for signed char + int"); |
| 21692 | |
| 21693 | cod_assoc_externs(context, externs); |
| 21694 | cod_parse_for_context(extern_string, context); |
| 21695 | |
| 21696 | cod_subroutine_declaration("signed char proc(signed char p1, int p2)", |
| 21697 | context); |
| 21698 | gen_code = cod_code_gen(code, context); |
| 21699 | proc = (signed char (*)(signed char, int))(long)gen_code->func; |
| 21700 | |
| 21701 | |
| 21702 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 21703 | signed char source1_c = src1c_vals[i]; |
| 21704 | for (j=0 ; j < sizeof(src2i_vals)/sizeof(src2i_vals[0]) ; j++) { |
| 21705 | int source2_i = src2i_vals[j]; |
| 21706 | |
| 21707 | signed char expected_result; |
| 21708 | signed char result; |
| 21709 | |
| 21710 | |
| 21711 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 21712 | |
| 21713 | expected_result = (signed char) (source1_c + source2_i); |
| 21714 | |
| 21715 | result = proc(source1_c, source2_i); |
| 21716 | if (expected_result != result) { |
| 21717 | printf("Failed signed char + int test, expected %d, got %d, for %d + %d\n", |
| 21718 | expected_result, result, source1_c, source2_i); |
| 21719 | if (dumped == 0) cod_dump(gen_code); |
| 21720 | failed++; |
| 21721 | dumped++; |
| 21722 | } |
| 21723 | } |
| 21724 | } |
| 21725 | if (verbose) printf(" done\n"); |
| 21726 | cod_free_parse_context(context); |
| 21727 | cod_code_free(gen_code); |
| 21728 | } |
| 21729 | if ((only_run_test == NULL((void*)0)) || |
| 21730 | (strcmp(only_run_test, "c+u") == 0)) { |
| 21731 | int i, j; |
| 21732 | static char code[] = "{\n\ |
| 21733 | signed char a = p1;\n\ |
| 21734 | unsigned int b = p2;\n\ |
| 21735 | return a + b;\n\ |
| 21736 | }"; |
| 21737 | |
| 21738 | signed char (*proc)(signed char a, unsigned int b); |
| 21739 | cod_parse_context context = new_cod_parse_context(); |
| 21740 | int dumped = 0; |
| 21741 | |
| 21742 | cod_code gen_code; |
| 21743 | |
| 21744 | /* test for signed char + unsigned int */ |
| 21745 | if (verbose) printf("test for signed char + unsigned int"); |
| 21746 | |
| 21747 | cod_assoc_externs(context, externs); |
| 21748 | cod_parse_for_context(extern_string, context); |
| 21749 | |
| 21750 | cod_subroutine_declaration("signed char proc(signed char p1, unsigned int p2)", |
| 21751 | context); |
| 21752 | gen_code = cod_code_gen(code, context); |
| 21753 | proc = (signed char (*)(signed char, unsigned int))(long)gen_code->func; |
| 21754 | |
| 21755 | |
| 21756 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 21757 | signed char source1_c = src1c_vals[i]; |
| 21758 | for (j=0 ; j < sizeof(src2u_vals)/sizeof(src2u_vals[0]) ; j++) { |
| 21759 | unsigned int source2_u = src2u_vals[j]; |
| 21760 | |
| 21761 | signed char expected_result; |
| 21762 | signed char result; |
| 21763 | |
| 21764 | |
| 21765 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 21766 | |
| 21767 | expected_result = (signed char) (source1_c + source2_u); |
| 21768 | |
| 21769 | result = proc(source1_c, source2_u); |
| 21770 | if (expected_result != result) { |
| 21771 | printf("Failed signed char + unsigned int test, expected %d, got %d, for %d + %u\n", |
| 21772 | expected_result, result, source1_c, source2_u); |
| 21773 | if (dumped == 0) cod_dump(gen_code); |
| 21774 | failed++; |
| 21775 | dumped++; |
| 21776 | } |
| 21777 | } |
| 21778 | } |
| 21779 | if (verbose) printf(" done\n"); |
| 21780 | cod_free_parse_context(context); |
| 21781 | cod_code_free(gen_code); |
| 21782 | } |
| 21783 | if ((only_run_test == NULL((void*)0)) || |
| 21784 | (strcmp(only_run_test, "c+ul") == 0)) { |
| 21785 | int i, j; |
| 21786 | static char code[] = "{\n\ |
| 21787 | signed char a = p1;\n\ |
| 21788 | unsigned long b = p2;\n\ |
| 21789 | return a + b;\n\ |
| 21790 | }"; |
| 21791 | |
| 21792 | signed char (*proc)(signed char a, unsigned long b); |
| 21793 | cod_parse_context context = new_cod_parse_context(); |
| 21794 | int dumped = 0; |
| 21795 | |
| 21796 | cod_code gen_code; |
| 21797 | |
| 21798 | /* test for signed char + unsigned long */ |
| 21799 | if (verbose) printf("test for signed char + unsigned long"); |
| 21800 | |
| 21801 | cod_assoc_externs(context, externs); |
| 21802 | cod_parse_for_context(extern_string, context); |
| 21803 | |
| 21804 | cod_subroutine_declaration("signed char proc(signed char p1, unsigned long p2)", |
| 21805 | context); |
| 21806 | gen_code = cod_code_gen(code, context); |
| 21807 | proc = (signed char (*)(signed char, unsigned long))(long)gen_code->func; |
| 21808 | |
| 21809 | |
| 21810 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 21811 | signed char source1_c = src1c_vals[i]; |
| 21812 | for (j=0 ; j < sizeof(src2ul_vals)/sizeof(src2ul_vals[0]) ; j++) { |
| 21813 | unsigned long source2_ul = src2ul_vals[j]; |
| 21814 | |
| 21815 | signed char expected_result; |
| 21816 | signed char result; |
| 21817 | |
| 21818 | |
| 21819 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 21820 | |
| 21821 | expected_result = (signed char) (source1_c + source2_ul); |
| 21822 | |
| 21823 | result = proc(source1_c, source2_ul); |
| 21824 | if (expected_result != result) { |
| 21825 | printf("Failed signed char + unsigned long test, expected %d, got %d, for %d + %lu\n", |
| 21826 | expected_result, result, source1_c, source2_ul); |
| 21827 | if (dumped == 0) cod_dump(gen_code); |
| 21828 | failed++; |
| 21829 | dumped++; |
| 21830 | } |
| 21831 | } |
| 21832 | } |
| 21833 | if (verbose) printf(" done\n"); |
| 21834 | cod_free_parse_context(context); |
| 21835 | cod_code_free(gen_code); |
| 21836 | } |
| 21837 | if ((only_run_test == NULL((void*)0)) || |
| 21838 | (strcmp(only_run_test, "c+l") == 0)) { |
| 21839 | int i, j; |
| 21840 | static char code[] = "{\n\ |
| 21841 | signed char a = p1;\n\ |
| 21842 | long b = p2;\n\ |
| 21843 | return a + b;\n\ |
| 21844 | }"; |
| 21845 | |
| 21846 | signed char (*proc)(signed char a, long b); |
| 21847 | cod_parse_context context = new_cod_parse_context(); |
| 21848 | int dumped = 0; |
| 21849 | |
| 21850 | cod_code gen_code; |
| 21851 | |
| 21852 | /* test for signed char + long */ |
| 21853 | if (verbose) printf("test for signed char + long"); |
| 21854 | |
| 21855 | cod_assoc_externs(context, externs); |
| 21856 | cod_parse_for_context(extern_string, context); |
| 21857 | |
| 21858 | cod_subroutine_declaration("signed char proc(signed char p1, long p2)", |
| 21859 | context); |
| 21860 | gen_code = cod_code_gen(code, context); |
| 21861 | proc = (signed char (*)(signed char, long))(long)gen_code->func; |
| 21862 | |
| 21863 | |
| 21864 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 21865 | signed char source1_c = src1c_vals[i]; |
| 21866 | for (j=0 ; j < sizeof(src2l_vals)/sizeof(src2l_vals[0]) ; j++) { |
| 21867 | long source2_l = src2l_vals[j]; |
| 21868 | |
| 21869 | signed char expected_result; |
| 21870 | signed char result; |
| 21871 | |
| 21872 | |
| 21873 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 21874 | |
| 21875 | expected_result = (signed char) (source1_c + source2_l); |
| 21876 | |
| 21877 | result = proc(source1_c, source2_l); |
| 21878 | if (expected_result != result) { |
| 21879 | printf("Failed signed char + long test, expected %d, got %d, for %d + %ld\n", |
| 21880 | expected_result, result, source1_c, source2_l); |
| 21881 | if (dumped == 0) cod_dump(gen_code); |
| 21882 | failed++; |
| 21883 | dumped++; |
| 21884 | } |
| 21885 | } |
| 21886 | } |
| 21887 | if (verbose) printf(" done\n"); |
| 21888 | cod_free_parse_context(context); |
| 21889 | cod_code_free(gen_code); |
| 21890 | } |
| 21891 | if ((only_run_test == NULL((void*)0)) || |
| 21892 | (strcmp(only_run_test, "c+f") == 0)) { |
| 21893 | int i, j; |
| 21894 | static char code[] = "{\n\ |
| 21895 | signed char a = p1;\n\ |
| 21896 | float b = p2;\n\ |
| 21897 | return a + b;\n\ |
| 21898 | }"; |
| 21899 | |
| 21900 | signed char (*proc)(signed char a, float b); |
| 21901 | cod_parse_context context = new_cod_parse_context(); |
| 21902 | int dumped = 0; |
| 21903 | |
| 21904 | cod_code gen_code; |
| 21905 | |
| 21906 | /* test for signed char + float */ |
| 21907 | if (verbose) printf("test for signed char + float"); |
| 21908 | |
| 21909 | cod_assoc_externs(context, externs); |
| 21910 | cod_parse_for_context(extern_string, context); |
| 21911 | |
| 21912 | cod_subroutine_declaration("signed char proc(signed char p1, float p2)", |
| 21913 | context); |
| 21914 | gen_code = cod_code_gen(code, context); |
| 21915 | proc = (signed char (*)(signed char, float))(long)gen_code->func; |
| 21916 | |
| 21917 | |
| 21918 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 21919 | signed char source1_c = src1c_vals[i]; |
| 21920 | for (j=0 ; j < sizeof(src2f_vals)/sizeof(src2f_vals[0]) ; j++) { |
| 21921 | float source2_f = src2f_vals[j]; |
| 21922 | double range = 0.000001 * (fabs((double)source1_c) + fabs((double)source2_f)); |
| 21923 | signed char expected_result; |
| 21924 | signed char result; |
| 21925 | |
| 21926 | |
| 21927 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 21928 | |
| 21929 | expected_result = (signed char) (source1_c + source2_f); |
| 21930 | |
| 21931 | result = proc(source1_c, source2_f); |
| 21932 | range += 1.0; |
| 21933 | if ((result > (expected_result + range)) || (result < (expected_result - range))) { |
| 21934 | printf("Failed signed char + float test, expected %d, got %d, for %d + %g\n", |
| 21935 | expected_result, result, source1_c, source2_f); |
| 21936 | if (dumped == 0) cod_dump(gen_code); |
| 21937 | failed++; |
| 21938 | dumped++; |
| 21939 | } |
| 21940 | } |
| 21941 | } |
| 21942 | if (verbose) printf(" done\n"); |
| 21943 | cod_free_parse_context(context); |
| 21944 | cod_code_free(gen_code); |
| 21945 | } |
| 21946 | if ((only_run_test == NULL((void*)0)) || |
| 21947 | (strcmp(only_run_test, "c+d") == 0)) { |
| 21948 | int i, j; |
| 21949 | static char code[] = "{\n\ |
| 21950 | signed char a = p1;\n\ |
| 21951 | double b = p2;\n\ |
| 21952 | return a + b;\n\ |
| 21953 | }"; |
| 21954 | |
| 21955 | signed char (*proc)(signed char a, double b); |
| 21956 | cod_parse_context context = new_cod_parse_context(); |
| 21957 | int dumped = 0; |
| 21958 | |
| 21959 | cod_code gen_code; |
| 21960 | |
| 21961 | /* test for signed char + double */ |
| 21962 | if (verbose) printf("test for signed char + double"); |
| 21963 | |
| 21964 | cod_assoc_externs(context, externs); |
| 21965 | cod_parse_for_context(extern_string, context); |
| 21966 | |
| 21967 | cod_subroutine_declaration("signed char proc(signed char p1, double p2)", |
| 21968 | context); |
| 21969 | gen_code = cod_code_gen(code, context); |
| 21970 | proc = (signed char (*)(signed char, double))(long)gen_code->func; |
| 21971 | |
| 21972 | |
| 21973 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 21974 | signed char source1_c = src1c_vals[i]; |
| 21975 | for (j=0 ; j < sizeof(src2d_vals)/sizeof(src2d_vals[0]) ; j++) { |
| 21976 | double source2_d = src2d_vals[j]; |
| 21977 | |
| 21978 | signed char expected_result; |
| 21979 | signed char result; |
| 21980 | |
| 21981 | |
| 21982 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 21983 | |
| 21984 | expected_result = (signed char) (source1_c + source2_d); |
| 21985 | |
| 21986 | result = proc(source1_c, source2_d); |
| 21987 | if (expected_result != result) { |
| 21988 | printf("Failed signed char + double test, expected %d, got %d, for %d + %g\n", |
| 21989 | expected_result, result, source1_c, source2_d); |
| 21990 | if (dumped == 0) cod_dump(gen_code); |
| 21991 | failed++; |
| 21992 | dumped++; |
| 21993 | } |
| 21994 | } |
| 21995 | } |
| 21996 | if (verbose) printf(" done\n"); |
| 21997 | cod_free_parse_context(context); |
| 21998 | cod_code_free(gen_code); |
| 21999 | } |
| 22000 | } |
| 22001 | void add_uc_tests() |
| 22002 | { |
| 22003 | if ((only_run_test == NULL((void*)0)) || |
| 22004 | (strcmp(only_run_test, "uc+c") == 0)) { |
| 22005 | int i, j; |
| 22006 | static char code[] = "{\n\ |
| 22007 | unsigned char a = p1;\n\ |
| 22008 | signed char b = p2;\n\ |
| 22009 | return a + b;\n\ |
| 22010 | }"; |
| 22011 | |
| 22012 | unsigned char (*proc)(unsigned char a, signed char b); |
| 22013 | cod_parse_context context = new_cod_parse_context(); |
| 22014 | int dumped = 0; |
| 22015 | |
| 22016 | cod_code gen_code; |
| 22017 | |
| 22018 | /* test for unsigned char + signed char */ |
| 22019 | if (verbose) printf("test for unsigned char + signed char"); |
| 22020 | |
| 22021 | cod_assoc_externs(context, externs); |
| 22022 | cod_parse_for_context(extern_string, context); |
| 22023 | |
| 22024 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, signed char p2)", |
| 22025 | context); |
| 22026 | gen_code = cod_code_gen(code, context); |
| 22027 | proc = (unsigned char (*)(unsigned char, signed char))(long)gen_code->func; |
| 22028 | |
| 22029 | |
| 22030 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 22031 | unsigned char source1_uc = src1uc_vals[i]; |
| 22032 | for (j=0 ; j < sizeof(src2c_vals)/sizeof(src2c_vals[0]) ; j++) { |
| 22033 | signed char source2_c = src2c_vals[j]; |
| 22034 | |
| 22035 | unsigned char expected_result; |
| 22036 | unsigned char result; |
| 22037 | |
| 22038 | |
| 22039 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 22040 | |
| 22041 | expected_result = (unsigned char) (source1_uc + source2_c); |
| 22042 | |
| 22043 | result = proc(source1_uc, source2_c); |
| 22044 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 22045 | if (expected_result != result) { |
| 22046 | printf("Failed unsigned char + signed char test, expected %u, got %u, for %u + %d\n", |
| 22047 | expected_result, result, source1_uc, source2_c); |
| 22048 | if (dumped == 0) cod_dump(gen_code); |
| 22049 | failed++; |
| 22050 | dumped++; |
| 22051 | } |
| 22052 | } |
| 22053 | } |
| 22054 | if (verbose) printf(" done\n"); |
| 22055 | cod_free_parse_context(context); |
| 22056 | cod_code_free(gen_code); |
| 22057 | } |
| 22058 | if ((only_run_test == NULL((void*)0)) || |
| 22059 | (strcmp(only_run_test, "uc+uc") == 0)) { |
| 22060 | int i, j; |
| 22061 | static char code[] = "{\n\ |
| 22062 | unsigned char a = p1;\n\ |
| 22063 | unsigned char b = p2;\n\ |
| 22064 | return a + b;\n\ |
| 22065 | }"; |
| 22066 | |
| 22067 | unsigned char (*proc)(unsigned char a, unsigned char b); |
| 22068 | cod_parse_context context = new_cod_parse_context(); |
| 22069 | int dumped = 0; |
| 22070 | |
| 22071 | cod_code gen_code; |
| 22072 | |
| 22073 | /* test for unsigned char + unsigned char */ |
| 22074 | if (verbose) printf("test for unsigned char + unsigned char"); |
| 22075 | |
| 22076 | cod_assoc_externs(context, externs); |
| 22077 | cod_parse_for_context(extern_string, context); |
| 22078 | |
| 22079 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, unsigned char p2)", |
| 22080 | context); |
| 22081 | gen_code = cod_code_gen(code, context); |
| 22082 | proc = (unsigned char (*)(unsigned char, unsigned char))(long)gen_code->func; |
| 22083 | |
| 22084 | |
| 22085 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 22086 | unsigned char source1_uc = src1uc_vals[i]; |
| 22087 | for (j=0 ; j < sizeof(src2uc_vals)/sizeof(src2uc_vals[0]) ; j++) { |
| 22088 | unsigned char source2_uc = src2uc_vals[j]; |
| 22089 | |
| 22090 | unsigned char expected_result; |
| 22091 | unsigned char result; |
| 22092 | |
| 22093 | |
| 22094 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 22095 | |
| 22096 | expected_result = (unsigned char) (source1_uc + source2_uc); |
| 22097 | |
| 22098 | result = proc(source1_uc, source2_uc); |
| 22099 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 22100 | if (expected_result != result) { |
| 22101 | printf("Failed unsigned char + unsigned char test, expected %u, got %u, for %u + %u\n", |
| 22102 | expected_result, result, source1_uc, source2_uc); |
| 22103 | if (dumped == 0) cod_dump(gen_code); |
| 22104 | failed++; |
| 22105 | dumped++; |
| 22106 | } |
| 22107 | } |
| 22108 | } |
| 22109 | if (verbose) printf(" done\n"); |
| 22110 | cod_free_parse_context(context); |
| 22111 | cod_code_free(gen_code); |
| 22112 | } |
| 22113 | if ((only_run_test == NULL((void*)0)) || |
| 22114 | (strcmp(only_run_test, "uc+s") == 0)) { |
| 22115 | int i, j; |
| 22116 | static char code[] = "{\n\ |
| 22117 | unsigned char a = p1;\n\ |
| 22118 | short b = p2;\n\ |
| 22119 | return a + b;\n\ |
| 22120 | }"; |
| 22121 | |
| 22122 | unsigned char (*proc)(unsigned char a, short b); |
| 22123 | cod_parse_context context = new_cod_parse_context(); |
| 22124 | int dumped = 0; |
| 22125 | |
| 22126 | cod_code gen_code; |
| 22127 | |
| 22128 | /* test for unsigned char + short */ |
| 22129 | if (verbose) printf("test for unsigned char + short"); |
| 22130 | |
| 22131 | cod_assoc_externs(context, externs); |
| 22132 | cod_parse_for_context(extern_string, context); |
| 22133 | |
| 22134 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, short p2)", |
| 22135 | context); |
| 22136 | gen_code = cod_code_gen(code, context); |
| 22137 | proc = (unsigned char (*)(unsigned char, short))(long)gen_code->func; |
| 22138 | |
| 22139 | |
| 22140 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 22141 | unsigned char source1_uc = src1uc_vals[i]; |
| 22142 | for (j=0 ; j < sizeof(src2s_vals)/sizeof(src2s_vals[0]) ; j++) { |
| 22143 | short source2_s = src2s_vals[j]; |
| 22144 | |
| 22145 | unsigned char expected_result; |
| 22146 | unsigned char result; |
| 22147 | |
| 22148 | |
| 22149 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 22150 | |
| 22151 | expected_result = (unsigned char) (source1_uc + source2_s); |
| 22152 | |
| 22153 | result = proc(source1_uc, source2_s); |
| 22154 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 22155 | if (expected_result != result) { |
| 22156 | printf("Failed unsigned char + short test, expected %u, got %u, for %u + %d\n", |
| 22157 | expected_result, result, source1_uc, source2_s); |
| 22158 | if (dumped == 0) cod_dump(gen_code); |
| 22159 | failed++; |
| 22160 | dumped++; |
| 22161 | } |
| 22162 | } |
| 22163 | } |
| 22164 | if (verbose) printf(" done\n"); |
| 22165 | cod_free_parse_context(context); |
| 22166 | cod_code_free(gen_code); |
| 22167 | } |
| 22168 | if ((only_run_test == NULL((void*)0)) || |
| 22169 | (strcmp(only_run_test, "uc+us") == 0)) { |
| 22170 | int i, j; |
| 22171 | static char code[] = "{\n\ |
| 22172 | unsigned char a = p1;\n\ |
| 22173 | unsigned short b = p2;\n\ |
| 22174 | return a + b;\n\ |
| 22175 | }"; |
| 22176 | |
| 22177 | unsigned char (*proc)(unsigned char a, unsigned short b); |
| 22178 | cod_parse_context context = new_cod_parse_context(); |
| 22179 | int dumped = 0; |
| 22180 | |
| 22181 | cod_code gen_code; |
| 22182 | |
| 22183 | /* test for unsigned char + unsigned short */ |
| 22184 | if (verbose) printf("test for unsigned char + unsigned short"); |
| 22185 | |
| 22186 | cod_assoc_externs(context, externs); |
| 22187 | cod_parse_for_context(extern_string, context); |
| 22188 | |
| 22189 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, unsigned short p2)", |
| 22190 | context); |
| 22191 | gen_code = cod_code_gen(code, context); |
| 22192 | proc = (unsigned char (*)(unsigned char, unsigned short))(long)gen_code->func; |
| 22193 | |
| 22194 | |
| 22195 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 22196 | unsigned char source1_uc = src1uc_vals[i]; |
| 22197 | for (j=0 ; j < sizeof(src2us_vals)/sizeof(src2us_vals[0]) ; j++) { |
| 22198 | unsigned short source2_us = src2us_vals[j]; |
| 22199 | |
| 22200 | unsigned char expected_result; |
| 22201 | unsigned char result; |
| 22202 | |
| 22203 | |
| 22204 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 22205 | |
| 22206 | expected_result = (unsigned char) (source1_uc + source2_us); |
| 22207 | |
| 22208 | result = proc(source1_uc, source2_us); |
| 22209 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 22210 | if (expected_result != result) { |
| 22211 | printf("Failed unsigned char + unsigned short test, expected %u, got %u, for %u + %u\n", |
| 22212 | expected_result, result, source1_uc, source2_us); |
| 22213 | if (dumped == 0) cod_dump(gen_code); |
| 22214 | failed++; |
| 22215 | dumped++; |
| 22216 | } |
| 22217 | } |
| 22218 | } |
| 22219 | if (verbose) printf(" done\n"); |
| 22220 | cod_free_parse_context(context); |
| 22221 | cod_code_free(gen_code); |
| 22222 | } |
| 22223 | if ((only_run_test == NULL((void*)0)) || |
| 22224 | (strcmp(only_run_test, "uc+i") == 0)) { |
| 22225 | int i, j; |
| 22226 | static char code[] = "{\n\ |
| 22227 | unsigned char a = p1;\n\ |
| 22228 | int b = p2;\n\ |
| 22229 | return a + b;\n\ |
| 22230 | }"; |
| 22231 | |
| 22232 | unsigned char (*proc)(unsigned char a, int b); |
| 22233 | cod_parse_context context = new_cod_parse_context(); |
| 22234 | int dumped = 0; |
| 22235 | |
| 22236 | cod_code gen_code; |
| 22237 | |
| 22238 | /* test for unsigned char + int */ |
| 22239 | if (verbose) printf("test for unsigned char + int"); |
| 22240 | |
| 22241 | cod_assoc_externs(context, externs); |
| 22242 | cod_parse_for_context(extern_string, context); |
| 22243 | |
| 22244 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, int p2)", |
| 22245 | context); |
| 22246 | gen_code = cod_code_gen(code, context); |
| 22247 | proc = (unsigned char (*)(unsigned char, int))(long)gen_code->func; |
| 22248 | |
| 22249 | |
| 22250 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 22251 | unsigned char source1_uc = src1uc_vals[i]; |
| 22252 | for (j=0 ; j < sizeof(src2i_vals)/sizeof(src2i_vals[0]) ; j++) { |
| 22253 | int source2_i = src2i_vals[j]; |
| 22254 | |
| 22255 | unsigned char expected_result; |
| 22256 | unsigned char result; |
| 22257 | |
| 22258 | |
| 22259 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 22260 | |
| 22261 | expected_result = (unsigned char) (source1_uc + source2_i); |
| 22262 | |
| 22263 | result = proc(source1_uc, source2_i); |
| 22264 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 22265 | if (expected_result != result) { |
| 22266 | printf("Failed unsigned char + int test, expected %u, got %u, for %u + %d\n", |
| 22267 | expected_result, result, source1_uc, source2_i); |
| 22268 | if (dumped == 0) cod_dump(gen_code); |
| 22269 | failed++; |
| 22270 | dumped++; |
| 22271 | } |
| 22272 | } |
| 22273 | } |
| 22274 | if (verbose) printf(" done\n"); |
| 22275 | cod_free_parse_context(context); |
| 22276 | cod_code_free(gen_code); |
| 22277 | } |
| 22278 | if ((only_run_test == NULL((void*)0)) || |
| 22279 | (strcmp(only_run_test, "uc+u") == 0)) { |
| 22280 | int i, j; |
| 22281 | static char code[] = "{\n\ |
| 22282 | unsigned char a = p1;\n\ |
| 22283 | unsigned int b = p2;\n\ |
| 22284 | return a + b;\n\ |
| 22285 | }"; |
| 22286 | |
| 22287 | unsigned char (*proc)(unsigned char a, unsigned int b); |
| 22288 | cod_parse_context context = new_cod_parse_context(); |
| 22289 | int dumped = 0; |
| 22290 | |
| 22291 | cod_code gen_code; |
| 22292 | |
| 22293 | /* test for unsigned char + unsigned int */ |
| 22294 | if (verbose) printf("test for unsigned char + unsigned int"); |
| 22295 | |
| 22296 | cod_assoc_externs(context, externs); |
| 22297 | cod_parse_for_context(extern_string, context); |
| 22298 | |
| 22299 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, unsigned int p2)", |
| 22300 | context); |
| 22301 | gen_code = cod_code_gen(code, context); |
| 22302 | proc = (unsigned char (*)(unsigned char, unsigned int))(long)gen_code->func; |
| 22303 | |
| 22304 | |
| 22305 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 22306 | unsigned char source1_uc = src1uc_vals[i]; |
| 22307 | for (j=0 ; j < sizeof(src2u_vals)/sizeof(src2u_vals[0]) ; j++) { |
| 22308 | unsigned int source2_u = src2u_vals[j]; |
| 22309 | |
| 22310 | unsigned char expected_result; |
| 22311 | unsigned char result; |
| 22312 | |
| 22313 | |
| 22314 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 22315 | |
| 22316 | expected_result = (unsigned char) (source1_uc + source2_u); |
| 22317 | |
| 22318 | result = proc(source1_uc, source2_u); |
| 22319 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 22320 | if (expected_result != result) { |
| 22321 | printf("Failed unsigned char + unsigned int test, expected %u, got %u, for %u + %u\n", |
| 22322 | expected_result, result, source1_uc, source2_u); |
| 22323 | if (dumped == 0) cod_dump(gen_code); |
| 22324 | failed++; |
| 22325 | dumped++; |
| 22326 | } |
| 22327 | } |
| 22328 | } |
| 22329 | if (verbose) printf(" done\n"); |
| 22330 | cod_free_parse_context(context); |
| 22331 | cod_code_free(gen_code); |
| 22332 | } |
| 22333 | if ((only_run_test == NULL((void*)0)) || |
| 22334 | (strcmp(only_run_test, "uc+ul") == 0)) { |
| 22335 | int i, j; |
| 22336 | static char code[] = "{\n\ |
| 22337 | unsigned char a = p1;\n\ |
| 22338 | unsigned long b = p2;\n\ |
| 22339 | return a + b;\n\ |
| 22340 | }"; |
| 22341 | |
| 22342 | unsigned char (*proc)(unsigned char a, unsigned long b); |
| 22343 | cod_parse_context context = new_cod_parse_context(); |
| 22344 | int dumped = 0; |
| 22345 | |
| 22346 | cod_code gen_code; |
| 22347 | |
| 22348 | /* test for unsigned char + unsigned long */ |
| 22349 | if (verbose) printf("test for unsigned char + unsigned long"); |
| 22350 | |
| 22351 | cod_assoc_externs(context, externs); |
| 22352 | cod_parse_for_context(extern_string, context); |
| 22353 | |
| 22354 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, unsigned long p2)", |
| 22355 | context); |
| 22356 | gen_code = cod_code_gen(code, context); |
| 22357 | proc = (unsigned char (*)(unsigned char, unsigned long))(long)gen_code->func; |
| 22358 | |
| 22359 | |
| 22360 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 22361 | unsigned char source1_uc = src1uc_vals[i]; |
| 22362 | for (j=0 ; j < sizeof(src2ul_vals)/sizeof(src2ul_vals[0]) ; j++) { |
| 22363 | unsigned long source2_ul = src2ul_vals[j]; |
| 22364 | |
| 22365 | unsigned char expected_result; |
| 22366 | unsigned char result; |
| 22367 | |
| 22368 | |
| 22369 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 22370 | |
| 22371 | expected_result = (unsigned char) (source1_uc + source2_ul); |
| 22372 | |
| 22373 | result = proc(source1_uc, source2_ul); |
| 22374 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 22375 | if (expected_result != result) { |
| 22376 | printf("Failed unsigned char + unsigned long test, expected %u, got %u, for %u + %lu\n", |
| 22377 | expected_result, result, source1_uc, source2_ul); |
| 22378 | if (dumped == 0) cod_dump(gen_code); |
| 22379 | failed++; |
| 22380 | dumped++; |
| 22381 | } |
| 22382 | } |
| 22383 | } |
| 22384 | if (verbose) printf(" done\n"); |
| 22385 | cod_free_parse_context(context); |
| 22386 | cod_code_free(gen_code); |
| 22387 | } |
| 22388 | if ((only_run_test == NULL((void*)0)) || |
| 22389 | (strcmp(only_run_test, "uc+l") == 0)) { |
| 22390 | int i, j; |
| 22391 | static char code[] = "{\n\ |
| 22392 | unsigned char a = p1;\n\ |
| 22393 | long b = p2;\n\ |
| 22394 | return a + b;\n\ |
| 22395 | }"; |
| 22396 | |
| 22397 | unsigned char (*proc)(unsigned char a, long b); |
| 22398 | cod_parse_context context = new_cod_parse_context(); |
| 22399 | int dumped = 0; |
| 22400 | |
| 22401 | cod_code gen_code; |
| 22402 | |
| 22403 | /* test for unsigned char + long */ |
| 22404 | if (verbose) printf("test for unsigned char + long"); |
| 22405 | |
| 22406 | cod_assoc_externs(context, externs); |
| 22407 | cod_parse_for_context(extern_string, context); |
| 22408 | |
| 22409 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, long p2)", |
| 22410 | context); |
| 22411 | gen_code = cod_code_gen(code, context); |
| 22412 | proc = (unsigned char (*)(unsigned char, long))(long)gen_code->func; |
| 22413 | |
| 22414 | |
| 22415 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 22416 | unsigned char source1_uc = src1uc_vals[i]; |
| 22417 | for (j=0 ; j < sizeof(src2l_vals)/sizeof(src2l_vals[0]) ; j++) { |
| 22418 | long source2_l = src2l_vals[j]; |
| 22419 | |
| 22420 | unsigned char expected_result; |
| 22421 | unsigned char result; |
| 22422 | |
| 22423 | |
| 22424 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 22425 | |
| 22426 | expected_result = (unsigned char) (source1_uc + source2_l); |
| 22427 | |
| 22428 | result = proc(source1_uc, source2_l); |
| 22429 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 22430 | if (expected_result != result) { |
| 22431 | printf("Failed unsigned char + long test, expected %u, got %u, for %u + %ld\n", |
| 22432 | expected_result, result, source1_uc, source2_l); |
| 22433 | if (dumped == 0) cod_dump(gen_code); |
| 22434 | failed++; |
| 22435 | dumped++; |
| 22436 | } |
| 22437 | } |
| 22438 | } |
| 22439 | if (verbose) printf(" done\n"); |
| 22440 | cod_free_parse_context(context); |
| 22441 | cod_code_free(gen_code); |
| 22442 | } |
| 22443 | if ((only_run_test == NULL((void*)0)) || |
| 22444 | (strcmp(only_run_test, "uc+f") == 0)) { |
| 22445 | int i, j; |
| 22446 | static char code[] = "{\n\ |
| 22447 | unsigned char a = p1;\n\ |
| 22448 | float b = p2;\n\ |
| 22449 | return a + b;\n\ |
| 22450 | }"; |
| 22451 | |
| 22452 | unsigned char (*proc)(unsigned char a, float b); |
| 22453 | cod_parse_context context = new_cod_parse_context(); |
| 22454 | int dumped = 0; |
| 22455 | |
| 22456 | cod_code gen_code; |
| 22457 | |
| 22458 | /* test for unsigned char + float */ |
| 22459 | if (verbose) printf("test for unsigned char + float"); |
| 22460 | |
| 22461 | cod_assoc_externs(context, externs); |
| 22462 | cod_parse_for_context(extern_string, context); |
| 22463 | |
| 22464 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, float p2)", |
| 22465 | context); |
| 22466 | gen_code = cod_code_gen(code, context); |
| 22467 | proc = (unsigned char (*)(unsigned char, float))(long)gen_code->func; |
| 22468 | |
| 22469 | |
| 22470 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 22471 | unsigned char source1_uc = src1uc_vals[i]; |
| 22472 | for (j=0 ; j < sizeof(src2f_vals)/sizeof(src2f_vals[0]) ; j++) { |
| 22473 | float source2_f = src2f_vals[j]; |
| 22474 | double range = 0.000001 * (fabs((double)source1_uc) + fabs((double)source2_f)); |
| 22475 | unsigned char expected_result; |
| 22476 | unsigned char result; |
| 22477 | |
| 22478 | |
| 22479 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 22480 | |
| 22481 | expected_result = (unsigned char) (source1_uc + source2_f); |
| 22482 | |
| 22483 | result = proc(source1_uc, source2_f); |
| 22484 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 22485 | range += 1.0; |
| 22486 | if ((result > (expected_result + range)) || (result < (expected_result - range))) { |
| 22487 | printf("Failed unsigned char + float test, expected %u, got %u, for %u + %g\n", |
| 22488 | expected_result, result, source1_uc, source2_f); |
| 22489 | if (dumped == 0) cod_dump(gen_code); |
| 22490 | failed++; |
| 22491 | dumped++; |
| 22492 | } |
| 22493 | } |
| 22494 | } |
| 22495 | if (verbose) printf(" done\n"); |
| 22496 | cod_free_parse_context(context); |
| 22497 | cod_code_free(gen_code); |
| 22498 | } |
| 22499 | if ((only_run_test == NULL((void*)0)) || |
| 22500 | (strcmp(only_run_test, "uc+d") == 0)) { |
| 22501 | int i, j; |
| 22502 | static char code[] = "{\n\ |
| 22503 | unsigned char a = p1;\n\ |
| 22504 | double b = p2;\n\ |
| 22505 | return a + b;\n\ |
| 22506 | }"; |
| 22507 | |
| 22508 | unsigned char (*proc)(unsigned char a, double b); |
| 22509 | cod_parse_context context = new_cod_parse_context(); |
| 22510 | int dumped = 0; |
| 22511 | |
| 22512 | cod_code gen_code; |
| 22513 | |
| 22514 | /* test for unsigned char + double */ |
| 22515 | if (verbose) printf("test for unsigned char + double"); |
| 22516 | |
| 22517 | cod_assoc_externs(context, externs); |
| 22518 | cod_parse_for_context(extern_string, context); |
| 22519 | |
| 22520 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, double p2)", |
| 22521 | context); |
| 22522 | gen_code = cod_code_gen(code, context); |
| 22523 | proc = (unsigned char (*)(unsigned char, double))(long)gen_code->func; |
| 22524 | |
| 22525 | |
| 22526 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 22527 | unsigned char source1_uc = src1uc_vals[i]; |
| 22528 | for (j=0 ; j < sizeof(src2d_vals)/sizeof(src2d_vals[0]) ; j++) { |
| 22529 | double source2_d = src2d_vals[j]; |
| 22530 | |
| 22531 | unsigned char expected_result; |
| 22532 | unsigned char result; |
| 22533 | |
| 22534 | |
| 22535 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 22536 | |
| 22537 | expected_result = (unsigned char) (source1_uc + source2_d); |
| 22538 | |
| 22539 | result = proc(source1_uc, source2_d); |
| 22540 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 22541 | if (expected_result != result) { |
| 22542 | printf("Failed unsigned char + double test, expected %u, got %u, for %u + %g\n", |
| 22543 | expected_result, result, source1_uc, source2_d); |
| 22544 | if (dumped == 0) cod_dump(gen_code); |
| 22545 | failed++; |
| 22546 | dumped++; |
| 22547 | } |
| 22548 | } |
| 22549 | } |
| 22550 | if (verbose) printf(" done\n"); |
| 22551 | cod_free_parse_context(context); |
| 22552 | cod_code_free(gen_code); |
| 22553 | } |
| 22554 | } |
| 22555 | void add_s_tests() |
| 22556 | { |
| 22557 | if ((only_run_test == NULL((void*)0)) || |
| 22558 | (strcmp(only_run_test, "s+c") == 0)) { |
| 22559 | int i, j; |
| 22560 | static char code[] = "{\n\ |
| 22561 | short a = p1;\n\ |
| 22562 | signed char b = p2;\n\ |
| 22563 | return a + b;\n\ |
| 22564 | }"; |
| 22565 | |
| 22566 | short (*proc)(short a, signed char b); |
| 22567 | cod_parse_context context = new_cod_parse_context(); |
| 22568 | int dumped = 0; |
| 22569 | |
| 22570 | cod_code gen_code; |
| 22571 | |
| 22572 | /* test for short + signed char */ |
| 22573 | if (verbose) printf("test for short + signed char"); |
| 22574 | |
| 22575 | cod_assoc_externs(context, externs); |
| 22576 | cod_parse_for_context(extern_string, context); |
| 22577 | |
| 22578 | cod_subroutine_declaration("short proc(short p1, signed char p2)", |
| 22579 | context); |
| 22580 | gen_code = cod_code_gen(code, context); |
| 22581 | proc = (short (*)(short, signed char))(long)gen_code->func; |
| 22582 | |
| 22583 | |
| 22584 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 22585 | short source1_s = src1s_vals[i]; |
| 22586 | for (j=0 ; j < sizeof(src2c_vals)/sizeof(src2c_vals[0]) ; j++) { |
| 22587 | signed char source2_c = src2c_vals[j]; |
| 22588 | |
| 22589 | short expected_result; |
| 22590 | short result; |
| 22591 | |
| 22592 | |
| 22593 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 22594 | |
| 22595 | expected_result = (short) (source1_s + source2_c); |
| 22596 | |
| 22597 | result = proc(source1_s, source2_c); |
| 22598 | if (expected_result != result) { |
| 22599 | printf("Failed short + signed char test, expected %d, got %d, for %d + %d\n", |
| 22600 | expected_result, result, source1_s, source2_c); |
| 22601 | if (dumped == 0) cod_dump(gen_code); |
| 22602 | failed++; |
| 22603 | dumped++; |
| 22604 | } |
| 22605 | } |
| 22606 | } |
| 22607 | if (verbose) printf(" done\n"); |
| 22608 | cod_free_parse_context(context); |
| 22609 | cod_code_free(gen_code); |
| 22610 | } |
| 22611 | if ((only_run_test == NULL((void*)0)) || |
| 22612 | (strcmp(only_run_test, "s+uc") == 0)) { |
| 22613 | int i, j; |
| 22614 | static char code[] = "{\n\ |
| 22615 | short a = p1;\n\ |
| 22616 | unsigned char b = p2;\n\ |
| 22617 | return a + b;\n\ |
| 22618 | }"; |
| 22619 | |
| 22620 | short (*proc)(short a, unsigned char b); |
| 22621 | cod_parse_context context = new_cod_parse_context(); |
| 22622 | int dumped = 0; |
| 22623 | |
| 22624 | cod_code gen_code; |
| 22625 | |
| 22626 | /* test for short + unsigned char */ |
| 22627 | if (verbose) printf("test for short + unsigned char"); |
| 22628 | |
| 22629 | cod_assoc_externs(context, externs); |
| 22630 | cod_parse_for_context(extern_string, context); |
| 22631 | |
| 22632 | cod_subroutine_declaration("short proc(short p1, unsigned char p2)", |
| 22633 | context); |
| 22634 | gen_code = cod_code_gen(code, context); |
| 22635 | proc = (short (*)(short, unsigned char))(long)gen_code->func; |
| 22636 | |
| 22637 | |
| 22638 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 22639 | short source1_s = src1s_vals[i]; |
| 22640 | for (j=0 ; j < sizeof(src2uc_vals)/sizeof(src2uc_vals[0]) ; j++) { |
| 22641 | unsigned char source2_uc = src2uc_vals[j]; |
| 22642 | |
| 22643 | short expected_result; |
| 22644 | short result; |
| 22645 | |
| 22646 | |
| 22647 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 22648 | |
| 22649 | expected_result = (short) (source1_s + source2_uc); |
| 22650 | |
| 22651 | result = proc(source1_s, source2_uc); |
| 22652 | if (expected_result != result) { |
| 22653 | printf("Failed short + unsigned char test, expected %d, got %d, for %d + %u\n", |
| 22654 | expected_result, result, source1_s, source2_uc); |
| 22655 | if (dumped == 0) cod_dump(gen_code); |
| 22656 | failed++; |
| 22657 | dumped++; |
| 22658 | } |
| 22659 | } |
| 22660 | } |
| 22661 | if (verbose) printf(" done\n"); |
| 22662 | cod_free_parse_context(context); |
| 22663 | cod_code_free(gen_code); |
| 22664 | } |
| 22665 | if ((only_run_test == NULL((void*)0)) || |
| 22666 | (strcmp(only_run_test, "s+s") == 0)) { |
| 22667 | int i, j; |
| 22668 | static char code[] = "{\n\ |
| 22669 | short a = p1;\n\ |
| 22670 | short b = p2;\n\ |
| 22671 | return a + b;\n\ |
| 22672 | }"; |
| 22673 | |
| 22674 | short (*proc)(short a, short b); |
| 22675 | cod_parse_context context = new_cod_parse_context(); |
| 22676 | int dumped = 0; |
| 22677 | |
| 22678 | cod_code gen_code; |
| 22679 | |
| 22680 | /* test for short + short */ |
| 22681 | if (verbose) printf("test for short + short"); |
| 22682 | |
| 22683 | cod_assoc_externs(context, externs); |
| 22684 | cod_parse_for_context(extern_string, context); |
| 22685 | |
| 22686 | cod_subroutine_declaration("short proc(short p1, short p2)", |
| 22687 | context); |
| 22688 | gen_code = cod_code_gen(code, context); |
| 22689 | proc = (short (*)(short, short))(long)gen_code->func; |
| 22690 | |
| 22691 | |
| 22692 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 22693 | short source1_s = src1s_vals[i]; |
| 22694 | for (j=0 ; j < sizeof(src2s_vals)/sizeof(src2s_vals[0]) ; j++) { |
| 22695 | short source2_s = src2s_vals[j]; |
| 22696 | |
| 22697 | short expected_result; |
| 22698 | short result; |
| 22699 | |
| 22700 | |
| 22701 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 22702 | |
| 22703 | expected_result = (short) (source1_s + source2_s); |
| 22704 | |
| 22705 | result = proc(source1_s, source2_s); |
| 22706 | if (expected_result != result) { |
| 22707 | printf("Failed short + short test, expected %d, got %d, for %d + %d\n", |
| 22708 | expected_result, result, source1_s, source2_s); |
| 22709 | if (dumped == 0) cod_dump(gen_code); |
| 22710 | failed++; |
| 22711 | dumped++; |
| 22712 | } |
| 22713 | } |
| 22714 | } |
| 22715 | if (verbose) printf(" done\n"); |
| 22716 | cod_free_parse_context(context); |
| 22717 | cod_code_free(gen_code); |
| 22718 | } |
| 22719 | if ((only_run_test == NULL((void*)0)) || |
| 22720 | (strcmp(only_run_test, "s+us") == 0)) { |
| 22721 | int i, j; |
| 22722 | static char code[] = "{\n\ |
| 22723 | short a = p1;\n\ |
| 22724 | unsigned short b = p2;\n\ |
| 22725 | return a + b;\n\ |
| 22726 | }"; |
| 22727 | |
| 22728 | short (*proc)(short a, unsigned short b); |
| 22729 | cod_parse_context context = new_cod_parse_context(); |
| 22730 | int dumped = 0; |
| 22731 | |
| 22732 | cod_code gen_code; |
| 22733 | |
| 22734 | /* test for short + unsigned short */ |
| 22735 | if (verbose) printf("test for short + unsigned short"); |
| 22736 | |
| 22737 | cod_assoc_externs(context, externs); |
| 22738 | cod_parse_for_context(extern_string, context); |
| 22739 | |
| 22740 | cod_subroutine_declaration("short proc(short p1, unsigned short p2)", |
| 22741 | context); |
| 22742 | gen_code = cod_code_gen(code, context); |
| 22743 | proc = (short (*)(short, unsigned short))(long)gen_code->func; |
| 22744 | |
| 22745 | |
| 22746 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 22747 | short source1_s = src1s_vals[i]; |
| 22748 | for (j=0 ; j < sizeof(src2us_vals)/sizeof(src2us_vals[0]) ; j++) { |
| 22749 | unsigned short source2_us = src2us_vals[j]; |
| 22750 | |
| 22751 | short expected_result; |
| 22752 | short result; |
| 22753 | |
| 22754 | |
| 22755 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 22756 | |
| 22757 | expected_result = (short) (source1_s + source2_us); |
| 22758 | |
| 22759 | result = proc(source1_s, source2_us); |
| 22760 | if (expected_result != result) { |
| 22761 | printf("Failed short + unsigned short test, expected %d, got %d, for %d + %u\n", |
| 22762 | expected_result, result, source1_s, source2_us); |
| 22763 | if (dumped == 0) cod_dump(gen_code); |
| 22764 | failed++; |
| 22765 | dumped++; |
| 22766 | } |
| 22767 | } |
| 22768 | } |
| 22769 | if (verbose) printf(" done\n"); |
| 22770 | cod_free_parse_context(context); |
| 22771 | cod_code_free(gen_code); |
| 22772 | } |
| 22773 | if ((only_run_test == NULL((void*)0)) || |
| 22774 | (strcmp(only_run_test, "s+i") == 0)) { |
| 22775 | int i, j; |
| 22776 | static char code[] = "{\n\ |
| 22777 | short a = p1;\n\ |
| 22778 | int b = p2;\n\ |
| 22779 | return a + b;\n\ |
| 22780 | }"; |
| 22781 | |
| 22782 | short (*proc)(short a, int b); |
| 22783 | cod_parse_context context = new_cod_parse_context(); |
| 22784 | int dumped = 0; |
| 22785 | |
| 22786 | cod_code gen_code; |
| 22787 | |
| 22788 | /* test for short + int */ |
| 22789 | if (verbose) printf("test for short + int"); |
| 22790 | |
| 22791 | cod_assoc_externs(context, externs); |
| 22792 | cod_parse_for_context(extern_string, context); |
| 22793 | |
| 22794 | cod_subroutine_declaration("short proc(short p1, int p2)", |
| 22795 | context); |
| 22796 | gen_code = cod_code_gen(code, context); |
| 22797 | proc = (short (*)(short, int))(long)gen_code->func; |
| 22798 | |
| 22799 | |
| 22800 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 22801 | short source1_s = src1s_vals[i]; |
| 22802 | for (j=0 ; j < sizeof(src2i_vals)/sizeof(src2i_vals[0]) ; j++) { |
| 22803 | int source2_i = src2i_vals[j]; |
| 22804 | |
| 22805 | short expected_result; |
| 22806 | short result; |
| 22807 | |
| 22808 | |
| 22809 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 22810 | |
| 22811 | expected_result = (short) (source1_s + source2_i); |
| 22812 | |
| 22813 | result = proc(source1_s, source2_i); |
| 22814 | if (expected_result != result) { |
| 22815 | printf("Failed short + int test, expected %d, got %d, for %d + %d\n", |
| 22816 | expected_result, result, source1_s, source2_i); |
| 22817 | if (dumped == 0) cod_dump(gen_code); |
| 22818 | failed++; |
| 22819 | dumped++; |
| 22820 | } |
| 22821 | } |
| 22822 | } |
| 22823 | if (verbose) printf(" done\n"); |
| 22824 | cod_free_parse_context(context); |
| 22825 | cod_code_free(gen_code); |
| 22826 | } |
| 22827 | if ((only_run_test == NULL((void*)0)) || |
| 22828 | (strcmp(only_run_test, "s+u") == 0)) { |
| 22829 | int i, j; |
| 22830 | static char code[] = "{\n\ |
| 22831 | short a = p1;\n\ |
| 22832 | unsigned int b = p2;\n\ |
| 22833 | return a + b;\n\ |
| 22834 | }"; |
| 22835 | |
| 22836 | short (*proc)(short a, unsigned int b); |
| 22837 | cod_parse_context context = new_cod_parse_context(); |
| 22838 | int dumped = 0; |
| 22839 | |
| 22840 | cod_code gen_code; |
| 22841 | |
| 22842 | /* test for short + unsigned int */ |
| 22843 | if (verbose) printf("test for short + unsigned int"); |
| 22844 | |
| 22845 | cod_assoc_externs(context, externs); |
| 22846 | cod_parse_for_context(extern_string, context); |
| 22847 | |
| 22848 | cod_subroutine_declaration("short proc(short p1, unsigned int p2)", |
| 22849 | context); |
| 22850 | gen_code = cod_code_gen(code, context); |
| 22851 | proc = (short (*)(short, unsigned int))(long)gen_code->func; |
| 22852 | |
| 22853 | |
| 22854 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 22855 | short source1_s = src1s_vals[i]; |
| 22856 | for (j=0 ; j < sizeof(src2u_vals)/sizeof(src2u_vals[0]) ; j++) { |
| 22857 | unsigned int source2_u = src2u_vals[j]; |
| 22858 | |
| 22859 | short expected_result; |
| 22860 | short result; |
| 22861 | |
| 22862 | |
| 22863 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 22864 | |
| 22865 | expected_result = (short) (source1_s + source2_u); |
| 22866 | |
| 22867 | result = proc(source1_s, source2_u); |
| 22868 | if (expected_result != result) { |
| 22869 | printf("Failed short + unsigned int test, expected %d, got %d, for %d + %u\n", |
| 22870 | expected_result, result, source1_s, source2_u); |
| 22871 | if (dumped == 0) cod_dump(gen_code); |
| 22872 | failed++; |
| 22873 | dumped++; |
| 22874 | } |
| 22875 | } |
| 22876 | } |
| 22877 | if (verbose) printf(" done\n"); |
| 22878 | cod_free_parse_context(context); |
| 22879 | cod_code_free(gen_code); |
| 22880 | } |
| 22881 | if ((only_run_test == NULL((void*)0)) || |
| 22882 | (strcmp(only_run_test, "s+ul") == 0)) { |
| 22883 | int i, j; |
| 22884 | static char code[] = "{\n\ |
| 22885 | short a = p1;\n\ |
| 22886 | unsigned long b = p2;\n\ |
| 22887 | return a + b;\n\ |
| 22888 | }"; |
| 22889 | |
| 22890 | short (*proc)(short a, unsigned long b); |
| 22891 | cod_parse_context context = new_cod_parse_context(); |
| 22892 | int dumped = 0; |
| 22893 | |
| 22894 | cod_code gen_code; |
| 22895 | |
| 22896 | /* test for short + unsigned long */ |
| 22897 | if (verbose) printf("test for short + unsigned long"); |
| 22898 | |
| 22899 | cod_assoc_externs(context, externs); |
| 22900 | cod_parse_for_context(extern_string, context); |
| 22901 | |
| 22902 | cod_subroutine_declaration("short proc(short p1, unsigned long p2)", |
| 22903 | context); |
| 22904 | gen_code = cod_code_gen(code, context); |
| 22905 | proc = (short (*)(short, unsigned long))(long)gen_code->func; |
| 22906 | |
| 22907 | |
| 22908 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 22909 | short source1_s = src1s_vals[i]; |
| 22910 | for (j=0 ; j < sizeof(src2ul_vals)/sizeof(src2ul_vals[0]) ; j++) { |
| 22911 | unsigned long source2_ul = src2ul_vals[j]; |
| 22912 | |
| 22913 | short expected_result; |
| 22914 | short result; |
| 22915 | |
| 22916 | |
| 22917 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 22918 | |
| 22919 | expected_result = (short) (source1_s + source2_ul); |
| 22920 | |
| 22921 | result = proc(source1_s, source2_ul); |
| 22922 | if (expected_result != result) { |
| 22923 | printf("Failed short + unsigned long test, expected %d, got %d, for %d + %lu\n", |
| 22924 | expected_result, result, source1_s, source2_ul); |
| 22925 | if (dumped == 0) cod_dump(gen_code); |
| 22926 | failed++; |
| 22927 | dumped++; |
| 22928 | } |
| 22929 | } |
| 22930 | } |
| 22931 | if (verbose) printf(" done\n"); |
| 22932 | cod_free_parse_context(context); |
| 22933 | cod_code_free(gen_code); |
| 22934 | } |
| 22935 | if ((only_run_test == NULL((void*)0)) || |
| 22936 | (strcmp(only_run_test, "s+l") == 0)) { |
| 22937 | int i, j; |
| 22938 | static char code[] = "{\n\ |
| 22939 | short a = p1;\n\ |
| 22940 | long b = p2;\n\ |
| 22941 | return a + b;\n\ |
| 22942 | }"; |
| 22943 | |
| 22944 | short (*proc)(short a, long b); |
| 22945 | cod_parse_context context = new_cod_parse_context(); |
| 22946 | int dumped = 0; |
| 22947 | |
| 22948 | cod_code gen_code; |
| 22949 | |
| 22950 | /* test for short + long */ |
| 22951 | if (verbose) printf("test for short + long"); |
| 22952 | |
| 22953 | cod_assoc_externs(context, externs); |
| 22954 | cod_parse_for_context(extern_string, context); |
| 22955 | |
| 22956 | cod_subroutine_declaration("short proc(short p1, long p2)", |
| 22957 | context); |
| 22958 | gen_code = cod_code_gen(code, context); |
| 22959 | proc = (short (*)(short, long))(long)gen_code->func; |
| 22960 | |
| 22961 | |
| 22962 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 22963 | short source1_s = src1s_vals[i]; |
| 22964 | for (j=0 ; j < sizeof(src2l_vals)/sizeof(src2l_vals[0]) ; j++) { |
| 22965 | long source2_l = src2l_vals[j]; |
| 22966 | |
| 22967 | short expected_result; |
| 22968 | short result; |
| 22969 | |
| 22970 | |
| 22971 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 22972 | |
| 22973 | expected_result = (short) (source1_s + source2_l); |
| 22974 | |
| 22975 | result = proc(source1_s, source2_l); |
| 22976 | if (expected_result != result) { |
| 22977 | printf("Failed short + long test, expected %d, got %d, for %d + %ld\n", |
| 22978 | expected_result, result, source1_s, source2_l); |
| 22979 | if (dumped == 0) cod_dump(gen_code); |
| 22980 | failed++; |
| 22981 | dumped++; |
| 22982 | } |
| 22983 | } |
| 22984 | } |
| 22985 | if (verbose) printf(" done\n"); |
| 22986 | cod_free_parse_context(context); |
| 22987 | cod_code_free(gen_code); |
| 22988 | } |
| 22989 | if ((only_run_test == NULL((void*)0)) || |
| 22990 | (strcmp(only_run_test, "s+f") == 0)) { |
| 22991 | int i, j; |
| 22992 | static char code[] = "{\n\ |
| 22993 | short a = p1;\n\ |
| 22994 | float b = p2;\n\ |
| 22995 | return a + b;\n\ |
| 22996 | }"; |
| 22997 | |
| 22998 | short (*proc)(short a, float b); |
| 22999 | cod_parse_context context = new_cod_parse_context(); |
| 23000 | int dumped = 0; |
| 23001 | |
| 23002 | cod_code gen_code; |
| 23003 | |
| 23004 | /* test for short + float */ |
| 23005 | if (verbose) printf("test for short + float"); |
| 23006 | |
| 23007 | cod_assoc_externs(context, externs); |
| 23008 | cod_parse_for_context(extern_string, context); |
| 23009 | |
| 23010 | cod_subroutine_declaration("short proc(short p1, float p2)", |
| 23011 | context); |
| 23012 | gen_code = cod_code_gen(code, context); |
| 23013 | proc = (short (*)(short, float))(long)gen_code->func; |
| 23014 | |
| 23015 | |
| 23016 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 23017 | short source1_s = src1s_vals[i]; |
| 23018 | for (j=0 ; j < sizeof(src2f_vals)/sizeof(src2f_vals[0]) ; j++) { |
| 23019 | float source2_f = src2f_vals[j]; |
| 23020 | double range = 0.000001 * (fabs((double)source1_s) + fabs((double)source2_f)); |
| 23021 | short expected_result; |
| 23022 | short result; |
| 23023 | |
| 23024 | |
| 23025 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 23026 | |
| 23027 | expected_result = (short) (source1_s + source2_f); |
| 23028 | |
| 23029 | result = proc(source1_s, source2_f); |
| 23030 | range += 1.0; |
| 23031 | if ((result > (expected_result + range)) || (result < (expected_result - range))) { |
| 23032 | printf("Failed short + float test, expected %d, got %d, for %d + %g\n", |
| 23033 | expected_result, result, source1_s, source2_f); |
| 23034 | if (dumped == 0) cod_dump(gen_code); |
| 23035 | failed++; |
| 23036 | dumped++; |
| 23037 | } |
| 23038 | } |
| 23039 | } |
| 23040 | if (verbose) printf(" done\n"); |
| 23041 | cod_free_parse_context(context); |
| 23042 | cod_code_free(gen_code); |
| 23043 | } |
| 23044 | if ((only_run_test == NULL((void*)0)) || |
| 23045 | (strcmp(only_run_test, "s+d") == 0)) { |
| 23046 | int i, j; |
| 23047 | static char code[] = "{\n\ |
| 23048 | short a = p1;\n\ |
| 23049 | double b = p2;\n\ |
| 23050 | return a + b;\n\ |
| 23051 | }"; |
| 23052 | |
| 23053 | short (*proc)(short a, double b); |
| 23054 | cod_parse_context context = new_cod_parse_context(); |
| 23055 | int dumped = 0; |
| 23056 | |
| 23057 | cod_code gen_code; |
| 23058 | |
| 23059 | /* test for short + double */ |
| 23060 | if (verbose) printf("test for short + double"); |
| 23061 | |
| 23062 | cod_assoc_externs(context, externs); |
| 23063 | cod_parse_for_context(extern_string, context); |
| 23064 | |
| 23065 | cod_subroutine_declaration("short proc(short p1, double p2)", |
| 23066 | context); |
| 23067 | gen_code = cod_code_gen(code, context); |
| 23068 | proc = (short (*)(short, double))(long)gen_code->func; |
| 23069 | |
| 23070 | |
| 23071 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 23072 | short source1_s = src1s_vals[i]; |
| 23073 | for (j=0 ; j < sizeof(src2d_vals)/sizeof(src2d_vals[0]) ; j++) { |
| 23074 | double source2_d = src2d_vals[j]; |
| 23075 | |
| 23076 | short expected_result; |
| 23077 | short result; |
| 23078 | |
| 23079 | |
| 23080 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 23081 | |
| 23082 | expected_result = (short) (source1_s + source2_d); |
| 23083 | |
| 23084 | result = proc(source1_s, source2_d); |
| 23085 | if (expected_result != result) { |
| 23086 | printf("Failed short + double test, expected %d, got %d, for %d + %g\n", |
| 23087 | expected_result, result, source1_s, source2_d); |
| 23088 | if (dumped == 0) cod_dump(gen_code); |
| 23089 | failed++; |
| 23090 | dumped++; |
| 23091 | } |
| 23092 | } |
| 23093 | } |
| 23094 | if (verbose) printf(" done\n"); |
| 23095 | cod_free_parse_context(context); |
| 23096 | cod_code_free(gen_code); |
| 23097 | } |
| 23098 | } |
| 23099 | void add_us_tests() |
| 23100 | { |
| 23101 | if ((only_run_test == NULL((void*)0)) || |
| 23102 | (strcmp(only_run_test, "us+c") == 0)) { |
| 23103 | int i, j; |
| 23104 | static char code[] = "{\n\ |
| 23105 | unsigned short a = p1;\n\ |
| 23106 | signed char b = p2;\n\ |
| 23107 | return a + b;\n\ |
| 23108 | }"; |
| 23109 | |
| 23110 | unsigned short (*proc)(unsigned short a, signed char b); |
| 23111 | cod_parse_context context = new_cod_parse_context(); |
| 23112 | int dumped = 0; |
| 23113 | |
| 23114 | cod_code gen_code; |
| 23115 | |
| 23116 | /* test for unsigned short + signed char */ |
| 23117 | if (verbose) printf("test for unsigned short + signed char"); |
| 23118 | |
| 23119 | cod_assoc_externs(context, externs); |
| 23120 | cod_parse_for_context(extern_string, context); |
| 23121 | |
| 23122 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, signed char p2)", |
| 23123 | context); |
| 23124 | gen_code = cod_code_gen(code, context); |
| 23125 | proc = (unsigned short (*)(unsigned short, signed char))(long)gen_code->func; |
| 23126 | |
| 23127 | |
| 23128 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 23129 | unsigned short source1_us = src1us_vals[i]; |
| 23130 | for (j=0 ; j < sizeof(src2c_vals)/sizeof(src2c_vals[0]) ; j++) { |
| 23131 | signed char source2_c = src2c_vals[j]; |
| 23132 | |
| 23133 | unsigned short expected_result; |
| 23134 | unsigned short result; |
| 23135 | |
| 23136 | |
| 23137 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 23138 | |
| 23139 | expected_result = (unsigned short) (source1_us + source2_c); |
| 23140 | |
| 23141 | result = proc(source1_us, source2_c); |
| 23142 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 23143 | if (expected_result != result) { |
| 23144 | printf("Failed unsigned short + signed char test, expected %u, got %u, for %u + %d\n", |
| 23145 | expected_result, result, source1_us, source2_c); |
| 23146 | if (dumped == 0) cod_dump(gen_code); |
| 23147 | failed++; |
| 23148 | dumped++; |
| 23149 | } |
| 23150 | } |
| 23151 | } |
| 23152 | if (verbose) printf(" done\n"); |
| 23153 | cod_free_parse_context(context); |
| 23154 | cod_code_free(gen_code); |
| 23155 | } |
| 23156 | if ((only_run_test == NULL((void*)0)) || |
| 23157 | (strcmp(only_run_test, "us+uc") == 0)) { |
| 23158 | int i, j; |
| 23159 | static char code[] = "{\n\ |
| 23160 | unsigned short a = p1;\n\ |
| 23161 | unsigned char b = p2;\n\ |
| 23162 | return a + b;\n\ |
| 23163 | }"; |
| 23164 | |
| 23165 | unsigned short (*proc)(unsigned short a, unsigned char b); |
| 23166 | cod_parse_context context = new_cod_parse_context(); |
| 23167 | int dumped = 0; |
| 23168 | |
| 23169 | cod_code gen_code; |
| 23170 | |
| 23171 | /* test for unsigned short + unsigned char */ |
| 23172 | if (verbose) printf("test for unsigned short + unsigned char"); |
| 23173 | |
| 23174 | cod_assoc_externs(context, externs); |
| 23175 | cod_parse_for_context(extern_string, context); |
| 23176 | |
| 23177 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, unsigned char p2)", |
| 23178 | context); |
| 23179 | gen_code = cod_code_gen(code, context); |
| 23180 | proc = (unsigned short (*)(unsigned short, unsigned char))(long)gen_code->func; |
| 23181 | |
| 23182 | |
| 23183 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 23184 | unsigned short source1_us = src1us_vals[i]; |
| 23185 | for (j=0 ; j < sizeof(src2uc_vals)/sizeof(src2uc_vals[0]) ; j++) { |
| 23186 | unsigned char source2_uc = src2uc_vals[j]; |
| 23187 | |
| 23188 | unsigned short expected_result; |
| 23189 | unsigned short result; |
| 23190 | |
| 23191 | |
| 23192 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 23193 | |
| 23194 | expected_result = (unsigned short) (source1_us + source2_uc); |
| 23195 | |
| 23196 | result = proc(source1_us, source2_uc); |
| 23197 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 23198 | if (expected_result != result) { |
| 23199 | printf("Failed unsigned short + unsigned char test, expected %u, got %u, for %u + %u\n", |
| 23200 | expected_result, result, source1_us, source2_uc); |
| 23201 | if (dumped == 0) cod_dump(gen_code); |
| 23202 | failed++; |
| 23203 | dumped++; |
| 23204 | } |
| 23205 | } |
| 23206 | } |
| 23207 | if (verbose) printf(" done\n"); |
| 23208 | cod_free_parse_context(context); |
| 23209 | cod_code_free(gen_code); |
| 23210 | } |
| 23211 | if ((only_run_test == NULL((void*)0)) || |
| 23212 | (strcmp(only_run_test, "us+s") == 0)) { |
| 23213 | int i, j; |
| 23214 | static char code[] = "{\n\ |
| 23215 | unsigned short a = p1;\n\ |
| 23216 | short b = p2;\n\ |
| 23217 | return a + b;\n\ |
| 23218 | }"; |
| 23219 | |
| 23220 | unsigned short (*proc)(unsigned short a, short b); |
| 23221 | cod_parse_context context = new_cod_parse_context(); |
| 23222 | int dumped = 0; |
| 23223 | |
| 23224 | cod_code gen_code; |
| 23225 | |
| 23226 | /* test for unsigned short + short */ |
| 23227 | if (verbose) printf("test for unsigned short + short"); |
| 23228 | |
| 23229 | cod_assoc_externs(context, externs); |
| 23230 | cod_parse_for_context(extern_string, context); |
| 23231 | |
| 23232 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, short p2)", |
| 23233 | context); |
| 23234 | gen_code = cod_code_gen(code, context); |
| 23235 | proc = (unsigned short (*)(unsigned short, short))(long)gen_code->func; |
| 23236 | |
| 23237 | |
| 23238 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 23239 | unsigned short source1_us = src1us_vals[i]; |
| 23240 | for (j=0 ; j < sizeof(src2s_vals)/sizeof(src2s_vals[0]) ; j++) { |
| 23241 | short source2_s = src2s_vals[j]; |
| 23242 | |
| 23243 | unsigned short expected_result; |
| 23244 | unsigned short result; |
| 23245 | |
| 23246 | |
| 23247 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 23248 | |
| 23249 | expected_result = (unsigned short) (source1_us + source2_s); |
| 23250 | |
| 23251 | result = proc(source1_us, source2_s); |
| 23252 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 23253 | if (expected_result != result) { |
| 23254 | printf("Failed unsigned short + short test, expected %u, got %u, for %u + %d\n", |
| 23255 | expected_result, result, source1_us, source2_s); |
| 23256 | if (dumped == 0) cod_dump(gen_code); |
| 23257 | failed++; |
| 23258 | dumped++; |
| 23259 | } |
| 23260 | } |
| 23261 | } |
| 23262 | if (verbose) printf(" done\n"); |
| 23263 | cod_free_parse_context(context); |
| 23264 | cod_code_free(gen_code); |
| 23265 | } |
| 23266 | if ((only_run_test == NULL((void*)0)) || |
| 23267 | (strcmp(only_run_test, "us+us") == 0)) { |
| 23268 | int i, j; |
| 23269 | static char code[] = "{\n\ |
| 23270 | unsigned short a = p1;\n\ |
| 23271 | unsigned short b = p2;\n\ |
| 23272 | return a + b;\n\ |
| 23273 | }"; |
| 23274 | |
| 23275 | unsigned short (*proc)(unsigned short a, unsigned short b); |
| 23276 | cod_parse_context context = new_cod_parse_context(); |
| 23277 | int dumped = 0; |
| 23278 | |
| 23279 | cod_code gen_code; |
| 23280 | |
| 23281 | /* test for unsigned short + unsigned short */ |
| 23282 | if (verbose) printf("test for unsigned short + unsigned short"); |
| 23283 | |
| 23284 | cod_assoc_externs(context, externs); |
| 23285 | cod_parse_for_context(extern_string, context); |
| 23286 | |
| 23287 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, unsigned short p2)", |
| 23288 | context); |
| 23289 | gen_code = cod_code_gen(code, context); |
| 23290 | proc = (unsigned short (*)(unsigned short, unsigned short))(long)gen_code->func; |
| 23291 | |
| 23292 | |
| 23293 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 23294 | unsigned short source1_us = src1us_vals[i]; |
| 23295 | for (j=0 ; j < sizeof(src2us_vals)/sizeof(src2us_vals[0]) ; j++) { |
| 23296 | unsigned short source2_us = src2us_vals[j]; |
| 23297 | |
| 23298 | unsigned short expected_result; |
| 23299 | unsigned short result; |
| 23300 | |
| 23301 | |
| 23302 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 23303 | |
| 23304 | expected_result = (unsigned short) (source1_us + source2_us); |
| 23305 | |
| 23306 | result = proc(source1_us, source2_us); |
| 23307 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 23308 | if (expected_result != result) { |
| 23309 | printf("Failed unsigned short + unsigned short test, expected %u, got %u, for %u + %u\n", |
| 23310 | expected_result, result, source1_us, source2_us); |
| 23311 | if (dumped == 0) cod_dump(gen_code); |
| 23312 | failed++; |
| 23313 | dumped++; |
| 23314 | } |
| 23315 | } |
| 23316 | } |
| 23317 | if (verbose) printf(" done\n"); |
| 23318 | cod_free_parse_context(context); |
| 23319 | cod_code_free(gen_code); |
| 23320 | } |
| 23321 | if ((only_run_test == NULL((void*)0)) || |
| 23322 | (strcmp(only_run_test, "us+i") == 0)) { |
| 23323 | int i, j; |
| 23324 | static char code[] = "{\n\ |
| 23325 | unsigned short a = p1;\n\ |
| 23326 | int b = p2;\n\ |
| 23327 | return a + b;\n\ |
| 23328 | }"; |
| 23329 | |
| 23330 | unsigned short (*proc)(unsigned short a, int b); |
| 23331 | cod_parse_context context = new_cod_parse_context(); |
| 23332 | int dumped = 0; |
| 23333 | |
| 23334 | cod_code gen_code; |
| 23335 | |
| 23336 | /* test for unsigned short + int */ |
| 23337 | if (verbose) printf("test for unsigned short + int"); |
| 23338 | |
| 23339 | cod_assoc_externs(context, externs); |
| 23340 | cod_parse_for_context(extern_string, context); |
| 23341 | |
| 23342 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, int p2)", |
| 23343 | context); |
| 23344 | gen_code = cod_code_gen(code, context); |
| 23345 | proc = (unsigned short (*)(unsigned short, int))(long)gen_code->func; |
| 23346 | |
| 23347 | |
| 23348 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 23349 | unsigned short source1_us = src1us_vals[i]; |
| 23350 | for (j=0 ; j < sizeof(src2i_vals)/sizeof(src2i_vals[0]) ; j++) { |
| 23351 | int source2_i = src2i_vals[j]; |
| 23352 | |
| 23353 | unsigned short expected_result; |
| 23354 | unsigned short result; |
| 23355 | |
| 23356 | |
| 23357 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 23358 | |
| 23359 | expected_result = (unsigned short) (source1_us + source2_i); |
| 23360 | |
| 23361 | result = proc(source1_us, source2_i); |
| 23362 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 23363 | if (expected_result != result) { |
| 23364 | printf("Failed unsigned short + int test, expected %u, got %u, for %u + %d\n", |
| 23365 | expected_result, result, source1_us, source2_i); |
| 23366 | if (dumped == 0) cod_dump(gen_code); |
| 23367 | failed++; |
| 23368 | dumped++; |
| 23369 | } |
| 23370 | } |
| 23371 | } |
| 23372 | if (verbose) printf(" done\n"); |
| 23373 | cod_free_parse_context(context); |
| 23374 | cod_code_free(gen_code); |
| 23375 | } |
| 23376 | if ((only_run_test == NULL((void*)0)) || |
| 23377 | (strcmp(only_run_test, "us+u") == 0)) { |
| 23378 | int i, j; |
| 23379 | static char code[] = "{\n\ |
| 23380 | unsigned short a = p1;\n\ |
| 23381 | unsigned int b = p2;\n\ |
| 23382 | return a + b;\n\ |
| 23383 | }"; |
| 23384 | |
| 23385 | unsigned short (*proc)(unsigned short a, unsigned int b); |
| 23386 | cod_parse_context context = new_cod_parse_context(); |
| 23387 | int dumped = 0; |
| 23388 | |
| 23389 | cod_code gen_code; |
| 23390 | |
| 23391 | /* test for unsigned short + unsigned int */ |
| 23392 | if (verbose) printf("test for unsigned short + unsigned int"); |
| 23393 | |
| 23394 | cod_assoc_externs(context, externs); |
| 23395 | cod_parse_for_context(extern_string, context); |
| 23396 | |
| 23397 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, unsigned int p2)", |
| 23398 | context); |
| 23399 | gen_code = cod_code_gen(code, context); |
| 23400 | proc = (unsigned short (*)(unsigned short, unsigned int))(long)gen_code->func; |
| 23401 | |
| 23402 | |
| 23403 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 23404 | unsigned short source1_us = src1us_vals[i]; |
| 23405 | for (j=0 ; j < sizeof(src2u_vals)/sizeof(src2u_vals[0]) ; j++) { |
| 23406 | unsigned int source2_u = src2u_vals[j]; |
| 23407 | |
| 23408 | unsigned short expected_result; |
| 23409 | unsigned short result; |
| 23410 | |
| 23411 | |
| 23412 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 23413 | |
| 23414 | expected_result = (unsigned short) (source1_us + source2_u); |
| 23415 | |
| 23416 | result = proc(source1_us, source2_u); |
| 23417 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 23418 | if (expected_result != result) { |
| 23419 | printf("Failed unsigned short + unsigned int test, expected %u, got %u, for %u + %u\n", |
| 23420 | expected_result, result, source1_us, source2_u); |
| 23421 | if (dumped == 0) cod_dump(gen_code); |
| 23422 | failed++; |
| 23423 | dumped++; |
| 23424 | } |
| 23425 | } |
| 23426 | } |
| 23427 | if (verbose) printf(" done\n"); |
| 23428 | cod_free_parse_context(context); |
| 23429 | cod_code_free(gen_code); |
| 23430 | } |
| 23431 | if ((only_run_test == NULL((void*)0)) || |
| 23432 | (strcmp(only_run_test, "us+ul") == 0)) { |
| 23433 | int i, j; |
| 23434 | static char code[] = "{\n\ |
| 23435 | unsigned short a = p1;\n\ |
| 23436 | unsigned long b = p2;\n\ |
| 23437 | return a + b;\n\ |
| 23438 | }"; |
| 23439 | |
| 23440 | unsigned short (*proc)(unsigned short a, unsigned long b); |
| 23441 | cod_parse_context context = new_cod_parse_context(); |
| 23442 | int dumped = 0; |
| 23443 | |
| 23444 | cod_code gen_code; |
| 23445 | |
| 23446 | /* test for unsigned short + unsigned long */ |
| 23447 | if (verbose) printf("test for unsigned short + unsigned long"); |
| 23448 | |
| 23449 | cod_assoc_externs(context, externs); |
| 23450 | cod_parse_for_context(extern_string, context); |
| 23451 | |
| 23452 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, unsigned long p2)", |
| 23453 | context); |
| 23454 | gen_code = cod_code_gen(code, context); |
| 23455 | proc = (unsigned short (*)(unsigned short, unsigned long))(long)gen_code->func; |
| 23456 | |
| 23457 | |
| 23458 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 23459 | unsigned short source1_us = src1us_vals[i]; |
| 23460 | for (j=0 ; j < sizeof(src2ul_vals)/sizeof(src2ul_vals[0]) ; j++) { |
| 23461 | unsigned long source2_ul = src2ul_vals[j]; |
| 23462 | |
| 23463 | unsigned short expected_result; |
| 23464 | unsigned short result; |
| 23465 | |
| 23466 | |
| 23467 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 23468 | |
| 23469 | expected_result = (unsigned short) (source1_us + source2_ul); |
| 23470 | |
| 23471 | result = proc(source1_us, source2_ul); |
| 23472 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 23473 | if (expected_result != result) { |
| 23474 | printf("Failed unsigned short + unsigned long test, expected %u, got %u, for %u + %lu\n", |
| 23475 | expected_result, result, source1_us, source2_ul); |
| 23476 | if (dumped == 0) cod_dump(gen_code); |
| 23477 | failed++; |
| 23478 | dumped++; |
| 23479 | } |
| 23480 | } |
| 23481 | } |
| 23482 | if (verbose) printf(" done\n"); |
| 23483 | cod_free_parse_context(context); |
| 23484 | cod_code_free(gen_code); |
| 23485 | } |
| 23486 | if ((only_run_test == NULL((void*)0)) || |
| 23487 | (strcmp(only_run_test, "us+l") == 0)) { |
| 23488 | int i, j; |
| 23489 | static char code[] = "{\n\ |
| 23490 | unsigned short a = p1;\n\ |
| 23491 | long b = p2;\n\ |
| 23492 | return a + b;\n\ |
| 23493 | }"; |
| 23494 | |
| 23495 | unsigned short (*proc)(unsigned short a, long b); |
| 23496 | cod_parse_context context = new_cod_parse_context(); |
| 23497 | int dumped = 0; |
| 23498 | |
| 23499 | cod_code gen_code; |
| 23500 | |
| 23501 | /* test for unsigned short + long */ |
| 23502 | if (verbose) printf("test for unsigned short + long"); |
| 23503 | |
| 23504 | cod_assoc_externs(context, externs); |
| 23505 | cod_parse_for_context(extern_string, context); |
| 23506 | |
| 23507 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, long p2)", |
| 23508 | context); |
| 23509 | gen_code = cod_code_gen(code, context); |
| 23510 | proc = (unsigned short (*)(unsigned short, long))(long)gen_code->func; |
| 23511 | |
| 23512 | |
| 23513 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 23514 | unsigned short source1_us = src1us_vals[i]; |
| 23515 | for (j=0 ; j < sizeof(src2l_vals)/sizeof(src2l_vals[0]) ; j++) { |
| 23516 | long source2_l = src2l_vals[j]; |
| 23517 | |
| 23518 | unsigned short expected_result; |
| 23519 | unsigned short result; |
| 23520 | |
| 23521 | |
| 23522 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 23523 | |
| 23524 | expected_result = (unsigned short) (source1_us + source2_l); |
| 23525 | |
| 23526 | result = proc(source1_us, source2_l); |
| 23527 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 23528 | if (expected_result != result) { |
| 23529 | printf("Failed unsigned short + long test, expected %u, got %u, for %u + %ld\n", |
| 23530 | expected_result, result, source1_us, source2_l); |
| 23531 | if (dumped == 0) cod_dump(gen_code); |
| 23532 | failed++; |
| 23533 | dumped++; |
| 23534 | } |
| 23535 | } |
| 23536 | } |
| 23537 | if (verbose) printf(" done\n"); |
| 23538 | cod_free_parse_context(context); |
| 23539 | cod_code_free(gen_code); |
| 23540 | } |
| 23541 | if ((only_run_test == NULL((void*)0)) || |
| 23542 | (strcmp(only_run_test, "us+f") == 0)) { |
| 23543 | int i, j; |
| 23544 | static char code[] = "{\n\ |
| 23545 | unsigned short a = p1;\n\ |
| 23546 | float b = p2;\n\ |
| 23547 | return a + b;\n\ |
| 23548 | }"; |
| 23549 | |
| 23550 | unsigned short (*proc)(unsigned short a, float b); |
| 23551 | cod_parse_context context = new_cod_parse_context(); |
| 23552 | int dumped = 0; |
| 23553 | |
| 23554 | cod_code gen_code; |
| 23555 | |
| 23556 | /* test for unsigned short + float */ |
| 23557 | if (verbose) printf("test for unsigned short + float"); |
| 23558 | |
| 23559 | cod_assoc_externs(context, externs); |
| 23560 | cod_parse_for_context(extern_string, context); |
| 23561 | |
| 23562 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, float p2)", |
| 23563 | context); |
| 23564 | gen_code = cod_code_gen(code, context); |
| 23565 | proc = (unsigned short (*)(unsigned short, float))(long)gen_code->func; |
| 23566 | |
| 23567 | |
| 23568 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 23569 | unsigned short source1_us = src1us_vals[i]; |
| 23570 | for (j=0 ; j < sizeof(src2f_vals)/sizeof(src2f_vals[0]) ; j++) { |
| 23571 | float source2_f = src2f_vals[j]; |
| 23572 | double range = 0.000001 * (fabs((double)source1_us) + fabs((double)source2_f)); |
| 23573 | unsigned short expected_result; |
| 23574 | unsigned short result; |
| 23575 | |
| 23576 | |
| 23577 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 23578 | |
| 23579 | expected_result = (unsigned short) (source1_us + source2_f); |
| 23580 | |
| 23581 | result = proc(source1_us, source2_f); |
| 23582 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 23583 | range += 1.0; |
| 23584 | if ((result > (expected_result + range)) || (result < (expected_result - range))) { |
| 23585 | printf("Failed unsigned short + float test, expected %u, got %u, for %u + %g\n", |
| 23586 | expected_result, result, source1_us, source2_f); |
| 23587 | if (dumped == 0) cod_dump(gen_code); |
| 23588 | failed++; |
| 23589 | dumped++; |
| 23590 | } |
| 23591 | } |
| 23592 | } |
| 23593 | if (verbose) printf(" done\n"); |
| 23594 | cod_free_parse_context(context); |
| 23595 | cod_code_free(gen_code); |
| 23596 | } |
| 23597 | if ((only_run_test == NULL((void*)0)) || |
| 23598 | (strcmp(only_run_test, "us+d") == 0)) { |
| 23599 | int i, j; |
| 23600 | static char code[] = "{\n\ |
| 23601 | unsigned short a = p1;\n\ |
| 23602 | double b = p2;\n\ |
| 23603 | return a + b;\n\ |
| 23604 | }"; |
| 23605 | |
| 23606 | unsigned short (*proc)(unsigned short a, double b); |
| 23607 | cod_parse_context context = new_cod_parse_context(); |
| 23608 | int dumped = 0; |
| 23609 | |
| 23610 | cod_code gen_code; |
| 23611 | |
| 23612 | /* test for unsigned short + double */ |
| 23613 | if (verbose) printf("test for unsigned short + double"); |
| 23614 | |
| 23615 | cod_assoc_externs(context, externs); |
| 23616 | cod_parse_for_context(extern_string, context); |
| 23617 | |
| 23618 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, double p2)", |
| 23619 | context); |
| 23620 | gen_code = cod_code_gen(code, context); |
| 23621 | proc = (unsigned short (*)(unsigned short, double))(long)gen_code->func; |
| 23622 | |
| 23623 | |
| 23624 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 23625 | unsigned short source1_us = src1us_vals[i]; |
| 23626 | for (j=0 ; j < sizeof(src2d_vals)/sizeof(src2d_vals[0]) ; j++) { |
| 23627 | double source2_d = src2d_vals[j]; |
| 23628 | |
| 23629 | unsigned short expected_result; |
| 23630 | unsigned short result; |
| 23631 | |
| 23632 | |
| 23633 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 23634 | |
| 23635 | expected_result = (unsigned short) (source1_us + source2_d); |
| 23636 | |
| 23637 | result = proc(source1_us, source2_d); |
| 23638 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 23639 | if (expected_result != result) { |
| 23640 | printf("Failed unsigned short + double test, expected %u, got %u, for %u + %g\n", |
| 23641 | expected_result, result, source1_us, source2_d); |
| 23642 | if (dumped == 0) cod_dump(gen_code); |
| 23643 | failed++; |
| 23644 | dumped++; |
| 23645 | } |
| 23646 | } |
| 23647 | } |
| 23648 | if (verbose) printf(" done\n"); |
| 23649 | cod_free_parse_context(context); |
| 23650 | cod_code_free(gen_code); |
| 23651 | } |
| 23652 | } |
| 23653 | void add_i_tests() |
| 23654 | { |
| 23655 | if ((only_run_test == NULL((void*)0)) || |
| 23656 | (strcmp(only_run_test, "i+c") == 0)) { |
| 23657 | int i, j; |
| 23658 | static char code[] = "{\n\ |
| 23659 | int a = p1;\n\ |
| 23660 | signed char b = p2;\n\ |
| 23661 | return a + b;\n\ |
| 23662 | }"; |
| 23663 | |
| 23664 | int (*proc)(int a, signed char b); |
| 23665 | cod_parse_context context = new_cod_parse_context(); |
| 23666 | int dumped = 0; |
| 23667 | |
| 23668 | cod_code gen_code; |
| 23669 | |
| 23670 | /* test for int + signed char */ |
| 23671 | if (verbose) printf("test for int + signed char"); |
| 23672 | |
| 23673 | cod_assoc_externs(context, externs); |
| 23674 | cod_parse_for_context(extern_string, context); |
| 23675 | |
| 23676 | cod_subroutine_declaration("int proc(int p1, signed char p2)", |
| 23677 | context); |
| 23678 | gen_code = cod_code_gen(code, context); |
| 23679 | proc = (int (*)(int, signed char))(long)gen_code->func; |
| 23680 | |
| 23681 | |
| 23682 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 23683 | int source1_i = src1i_vals[i]; |
| 23684 | for (j=0 ; j < sizeof(src2c_vals)/sizeof(src2c_vals[0]) ; j++) { |
| 23685 | signed char source2_c = src2c_vals[j]; |
| 23686 | |
| 23687 | int expected_result; |
| 23688 | int result; |
| 23689 | |
| 23690 | |
| 23691 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 23692 | |
| 23693 | expected_result = (int) (source1_i + source2_c); |
| 23694 | |
| 23695 | result = proc(source1_i, source2_c); |
| 23696 | if (expected_result != result) { |
| 23697 | printf("Failed int + signed char test, expected %d, got %d, for %d + %d\n", |
| 23698 | expected_result, result, source1_i, source2_c); |
| 23699 | if (dumped == 0) cod_dump(gen_code); |
| 23700 | failed++; |
| 23701 | dumped++; |
| 23702 | } |
| 23703 | } |
| 23704 | } |
| 23705 | if (verbose) printf(" done\n"); |
| 23706 | cod_free_parse_context(context); |
| 23707 | cod_code_free(gen_code); |
| 23708 | } |
| 23709 | if ((only_run_test == NULL((void*)0)) || |
| 23710 | (strcmp(only_run_test, "i+uc") == 0)) { |
| 23711 | int i, j; |
| 23712 | static char code[] = "{\n\ |
| 23713 | int a = p1;\n\ |
| 23714 | unsigned char b = p2;\n\ |
| 23715 | return a + b;\n\ |
| 23716 | }"; |
| 23717 | |
| 23718 | int (*proc)(int a, unsigned char b); |
| 23719 | cod_parse_context context = new_cod_parse_context(); |
| 23720 | int dumped = 0; |
| 23721 | |
| 23722 | cod_code gen_code; |
| 23723 | |
| 23724 | /* test for int + unsigned char */ |
| 23725 | if (verbose) printf("test for int + unsigned char"); |
| 23726 | |
| 23727 | cod_assoc_externs(context, externs); |
| 23728 | cod_parse_for_context(extern_string, context); |
| 23729 | |
| 23730 | cod_subroutine_declaration("int proc(int p1, unsigned char p2)", |
| 23731 | context); |
| 23732 | gen_code = cod_code_gen(code, context); |
| 23733 | proc = (int (*)(int, unsigned char))(long)gen_code->func; |
| 23734 | |
| 23735 | |
| 23736 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 23737 | int source1_i = src1i_vals[i]; |
| 23738 | for (j=0 ; j < sizeof(src2uc_vals)/sizeof(src2uc_vals[0]) ; j++) { |
| 23739 | unsigned char source2_uc = src2uc_vals[j]; |
| 23740 | |
| 23741 | int expected_result; |
| 23742 | int result; |
| 23743 | |
| 23744 | |
| 23745 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 23746 | |
| 23747 | expected_result = (int) (source1_i + source2_uc); |
| 23748 | |
| 23749 | result = proc(source1_i, source2_uc); |
| 23750 | if (expected_result != result) { |
| 23751 | printf("Failed int + unsigned char test, expected %d, got %d, for %d + %u\n", |
| 23752 | expected_result, result, source1_i, source2_uc); |
| 23753 | if (dumped == 0) cod_dump(gen_code); |
| 23754 | failed++; |
| 23755 | dumped++; |
| 23756 | } |
| 23757 | } |
| 23758 | } |
| 23759 | if (verbose) printf(" done\n"); |
| 23760 | cod_free_parse_context(context); |
| 23761 | cod_code_free(gen_code); |
| 23762 | } |
| 23763 | if ((only_run_test == NULL((void*)0)) || |
| 23764 | (strcmp(only_run_test, "i+s") == 0)) { |
| 23765 | int i, j; |
| 23766 | static char code[] = "{\n\ |
| 23767 | int a = p1;\n\ |
| 23768 | short b = p2;\n\ |
| 23769 | return a + b;\n\ |
| 23770 | }"; |
| 23771 | |
| 23772 | int (*proc)(int a, short b); |
| 23773 | cod_parse_context context = new_cod_parse_context(); |
| 23774 | int dumped = 0; |
| 23775 | |
| 23776 | cod_code gen_code; |
| 23777 | |
| 23778 | /* test for int + short */ |
| 23779 | if (verbose) printf("test for int + short"); |
| 23780 | |
| 23781 | cod_assoc_externs(context, externs); |
| 23782 | cod_parse_for_context(extern_string, context); |
| 23783 | |
| 23784 | cod_subroutine_declaration("int proc(int p1, short p2)", |
| 23785 | context); |
| 23786 | gen_code = cod_code_gen(code, context); |
| 23787 | proc = (int (*)(int, short))(long)gen_code->func; |
| 23788 | |
| 23789 | |
| 23790 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 23791 | int source1_i = src1i_vals[i]; |
| 23792 | for (j=0 ; j < sizeof(src2s_vals)/sizeof(src2s_vals[0]) ; j++) { |
| 23793 | short source2_s = src2s_vals[j]; |
| 23794 | |
| 23795 | int expected_result; |
| 23796 | int result; |
| 23797 | |
| 23798 | |
| 23799 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 23800 | |
| 23801 | expected_result = (int) (source1_i + source2_s); |
| 23802 | |
| 23803 | result = proc(source1_i, source2_s); |
| 23804 | if (expected_result != result) { |
| 23805 | printf("Failed int + short test, expected %d, got %d, for %d + %d\n", |
| 23806 | expected_result, result, source1_i, source2_s); |
| 23807 | if (dumped == 0) cod_dump(gen_code); |
| 23808 | failed++; |
| 23809 | dumped++; |
| 23810 | } |
| 23811 | } |
| 23812 | } |
| 23813 | if (verbose) printf(" done\n"); |
| 23814 | cod_free_parse_context(context); |
| 23815 | cod_code_free(gen_code); |
| 23816 | } |
| 23817 | if ((only_run_test == NULL((void*)0)) || |
| 23818 | (strcmp(only_run_test, "i+us") == 0)) { |
| 23819 | int i, j; |
| 23820 | static char code[] = "{\n\ |
| 23821 | int a = p1;\n\ |
| 23822 | unsigned short b = p2;\n\ |
| 23823 | return a + b;\n\ |
| 23824 | }"; |
| 23825 | |
| 23826 | int (*proc)(int a, unsigned short b); |
| 23827 | cod_parse_context context = new_cod_parse_context(); |
| 23828 | int dumped = 0; |
| 23829 | |
| 23830 | cod_code gen_code; |
| 23831 | |
| 23832 | /* test for int + unsigned short */ |
| 23833 | if (verbose) printf("test for int + unsigned short"); |
| 23834 | |
| 23835 | cod_assoc_externs(context, externs); |
| 23836 | cod_parse_for_context(extern_string, context); |
| 23837 | |
| 23838 | cod_subroutine_declaration("int proc(int p1, unsigned short p2)", |
| 23839 | context); |
| 23840 | gen_code = cod_code_gen(code, context); |
| 23841 | proc = (int (*)(int, unsigned short))(long)gen_code->func; |
| 23842 | |
| 23843 | |
| 23844 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 23845 | int source1_i = src1i_vals[i]; |
| 23846 | for (j=0 ; j < sizeof(src2us_vals)/sizeof(src2us_vals[0]) ; j++) { |
| 23847 | unsigned short source2_us = src2us_vals[j]; |
| 23848 | |
| 23849 | int expected_result; |
| 23850 | int result; |
| 23851 | |
| 23852 | |
| 23853 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 23854 | |
| 23855 | expected_result = (int) (source1_i + source2_us); |
| 23856 | |
| 23857 | result = proc(source1_i, source2_us); |
| 23858 | if (expected_result != result) { |
| 23859 | printf("Failed int + unsigned short test, expected %d, got %d, for %d + %u\n", |
| 23860 | expected_result, result, source1_i, source2_us); |
| 23861 | if (dumped == 0) cod_dump(gen_code); |
| 23862 | failed++; |
| 23863 | dumped++; |
| 23864 | } |
| 23865 | } |
| 23866 | } |
| 23867 | if (verbose) printf(" done\n"); |
| 23868 | cod_free_parse_context(context); |
| 23869 | cod_code_free(gen_code); |
| 23870 | } |
| 23871 | if ((only_run_test == NULL((void*)0)) || |
| 23872 | (strcmp(only_run_test, "i+i") == 0)) { |
| 23873 | int i, j; |
| 23874 | static char code[] = "{\n\ |
| 23875 | int a = p1;\n\ |
| 23876 | int b = p2;\n\ |
| 23877 | return a + b;\n\ |
| 23878 | }"; |
| 23879 | |
| 23880 | int (*proc)(int a, int b); |
| 23881 | cod_parse_context context = new_cod_parse_context(); |
| 23882 | int dumped = 0; |
| 23883 | |
| 23884 | cod_code gen_code; |
| 23885 | |
| 23886 | /* test for int + int */ |
| 23887 | if (verbose) printf("test for int + int"); |
| 23888 | |
| 23889 | cod_assoc_externs(context, externs); |
| 23890 | cod_parse_for_context(extern_string, context); |
| 23891 | |
| 23892 | cod_subroutine_declaration("int proc(int p1, int p2)", |
| 23893 | context); |
| 23894 | gen_code = cod_code_gen(code, context); |
| 23895 | proc = (int (*)(int, int))(long)gen_code->func; |
| 23896 | |
| 23897 | |
| 23898 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 23899 | int source1_i = src1i_vals[i]; |
| 23900 | for (j=0 ; j < sizeof(src2i_vals)/sizeof(src2i_vals[0]) ; j++) { |
| 23901 | int source2_i = src2i_vals[j]; |
| 23902 | |
| 23903 | int expected_result; |
| 23904 | int result; |
| 23905 | |
| 23906 | |
| 23907 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 23908 | |
| 23909 | expected_result = (int) (source1_i + source2_i); |
| 23910 | |
| 23911 | result = proc(source1_i, source2_i); |
| 23912 | if (expected_result != result) { |
| 23913 | printf("Failed int + int test, expected %d, got %d, for %d + %d\n", |
| 23914 | expected_result, result, source1_i, source2_i); |
| 23915 | if (dumped == 0) cod_dump(gen_code); |
| 23916 | failed++; |
| 23917 | dumped++; |
| 23918 | } |
| 23919 | } |
| 23920 | } |
| 23921 | if (verbose) printf(" done\n"); |
| 23922 | cod_free_parse_context(context); |
| 23923 | cod_code_free(gen_code); |
| 23924 | } |
| 23925 | if ((only_run_test == NULL((void*)0)) || |
| 23926 | (strcmp(only_run_test, "i+u") == 0)) { |
| 23927 | int i, j; |
| 23928 | static char code[] = "{\n\ |
| 23929 | int a = p1;\n\ |
| 23930 | unsigned int b = p2;\n\ |
| 23931 | return a + b;\n\ |
| 23932 | }"; |
| 23933 | |
| 23934 | int (*proc)(int a, unsigned int b); |
| 23935 | cod_parse_context context = new_cod_parse_context(); |
| 23936 | int dumped = 0; |
| 23937 | |
| 23938 | cod_code gen_code; |
| 23939 | |
| 23940 | /* test for int + unsigned int */ |
| 23941 | if (verbose) printf("test for int + unsigned int"); |
| 23942 | |
| 23943 | cod_assoc_externs(context, externs); |
| 23944 | cod_parse_for_context(extern_string, context); |
| 23945 | |
| 23946 | cod_subroutine_declaration("int proc(int p1, unsigned int p2)", |
| 23947 | context); |
| 23948 | gen_code = cod_code_gen(code, context); |
| 23949 | proc = (int (*)(int, unsigned int))(long)gen_code->func; |
| 23950 | |
| 23951 | |
| 23952 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 23953 | int source1_i = src1i_vals[i]; |
| 23954 | for (j=0 ; j < sizeof(src2u_vals)/sizeof(src2u_vals[0]) ; j++) { |
| 23955 | unsigned int source2_u = src2u_vals[j]; |
| 23956 | |
| 23957 | int expected_result; |
| 23958 | int result; |
| 23959 | |
| 23960 | |
| 23961 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 23962 | |
| 23963 | expected_result = (int) (source1_i + source2_u); |
| 23964 | |
| 23965 | result = proc(source1_i, source2_u); |
| 23966 | if (expected_result != result) { |
| 23967 | printf("Failed int + unsigned int test, expected %d, got %d, for %d + %u\n", |
| 23968 | expected_result, result, source1_i, source2_u); |
| 23969 | if (dumped == 0) cod_dump(gen_code); |
| 23970 | failed++; |
| 23971 | dumped++; |
| 23972 | } |
| 23973 | } |
| 23974 | } |
| 23975 | if (verbose) printf(" done\n"); |
| 23976 | cod_free_parse_context(context); |
| 23977 | cod_code_free(gen_code); |
| 23978 | } |
| 23979 | if ((only_run_test == NULL((void*)0)) || |
| 23980 | (strcmp(only_run_test, "i+ul") == 0)) { |
| 23981 | int i, j; |
| 23982 | static char code[] = "{\n\ |
| 23983 | int a = p1;\n\ |
| 23984 | unsigned long b = p2;\n\ |
| 23985 | return a + b;\n\ |
| 23986 | }"; |
| 23987 | |
| 23988 | int (*proc)(int a, unsigned long b); |
| 23989 | cod_parse_context context = new_cod_parse_context(); |
| 23990 | int dumped = 0; |
| 23991 | |
| 23992 | cod_code gen_code; |
| 23993 | |
| 23994 | /* test for int + unsigned long */ |
| 23995 | if (verbose) printf("test for int + unsigned long"); |
| 23996 | |
| 23997 | cod_assoc_externs(context, externs); |
| 23998 | cod_parse_for_context(extern_string, context); |
| 23999 | |
| 24000 | cod_subroutine_declaration("int proc(int p1, unsigned long p2)", |
| 24001 | context); |
| 24002 | gen_code = cod_code_gen(code, context); |
| 24003 | proc = (int (*)(int, unsigned long))(long)gen_code->func; |
| 24004 | |
| 24005 | |
| 24006 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 24007 | int source1_i = src1i_vals[i]; |
| 24008 | for (j=0 ; j < sizeof(src2ul_vals)/sizeof(src2ul_vals[0]) ; j++) { |
| 24009 | unsigned long source2_ul = src2ul_vals[j]; |
| 24010 | |
| 24011 | int expected_result; |
| 24012 | int result; |
| 24013 | |
| 24014 | |
| 24015 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 24016 | |
| 24017 | expected_result = (int) (source1_i + source2_ul); |
| 24018 | |
| 24019 | result = proc(source1_i, source2_ul); |
| 24020 | if (expected_result != result) { |
| 24021 | printf("Failed int + unsigned long test, expected %d, got %d, for %d + %lu\n", |
| 24022 | expected_result, result, source1_i, source2_ul); |
| 24023 | if (dumped == 0) cod_dump(gen_code); |
| 24024 | failed++; |
| 24025 | dumped++; |
| 24026 | } |
| 24027 | } |
| 24028 | } |
| 24029 | if (verbose) printf(" done\n"); |
| 24030 | cod_free_parse_context(context); |
| 24031 | cod_code_free(gen_code); |
| 24032 | } |
| 24033 | if ((only_run_test == NULL((void*)0)) || |
| 24034 | (strcmp(only_run_test, "i+l") == 0)) { |
| 24035 | int i, j; |
| 24036 | static char code[] = "{\n\ |
| 24037 | int a = p1;\n\ |
| 24038 | long b = p2;\n\ |
| 24039 | return a + b;\n\ |
| 24040 | }"; |
| 24041 | |
| 24042 | int (*proc)(int a, long b); |
| 24043 | cod_parse_context context = new_cod_parse_context(); |
| 24044 | int dumped = 0; |
| 24045 | |
| 24046 | cod_code gen_code; |
| 24047 | |
| 24048 | /* test for int + long */ |
| 24049 | if (verbose) printf("test for int + long"); |
| 24050 | |
| 24051 | cod_assoc_externs(context, externs); |
| 24052 | cod_parse_for_context(extern_string, context); |
| 24053 | |
| 24054 | cod_subroutine_declaration("int proc(int p1, long p2)", |
| 24055 | context); |
| 24056 | gen_code = cod_code_gen(code, context); |
| 24057 | proc = (int (*)(int, long))(long)gen_code->func; |
| 24058 | |
| 24059 | |
| 24060 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 24061 | int source1_i = src1i_vals[i]; |
| 24062 | for (j=0 ; j < sizeof(src2l_vals)/sizeof(src2l_vals[0]) ; j++) { |
| 24063 | long source2_l = src2l_vals[j]; |
| 24064 | |
| 24065 | int expected_result; |
| 24066 | int result; |
| 24067 | |
| 24068 | |
| 24069 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 24070 | |
| 24071 | expected_result = (int) (source1_i + source2_l); |
| 24072 | |
| 24073 | result = proc(source1_i, source2_l); |
| 24074 | if (expected_result != result) { |
| 24075 | printf("Failed int + long test, expected %d, got %d, for %d + %ld\n", |
| 24076 | expected_result, result, source1_i, source2_l); |
| 24077 | if (dumped == 0) cod_dump(gen_code); |
| 24078 | failed++; |
| 24079 | dumped++; |
| 24080 | } |
| 24081 | } |
| 24082 | } |
| 24083 | if (verbose) printf(" done\n"); |
| 24084 | cod_free_parse_context(context); |
| 24085 | cod_code_free(gen_code); |
| 24086 | } |
| 24087 | if ((only_run_test == NULL((void*)0)) || |
| 24088 | (strcmp(only_run_test, "i+f") == 0)) { |
| 24089 | int i, j; |
| 24090 | static char code[] = "{\n\ |
| 24091 | int a = p1;\n\ |
| 24092 | float b = p2;\n\ |
| 24093 | return a + b;\n\ |
| 24094 | }"; |
| 24095 | |
| 24096 | int (*proc)(int a, float b); |
| 24097 | cod_parse_context context = new_cod_parse_context(); |
| 24098 | int dumped = 0; |
| 24099 | |
| 24100 | cod_code gen_code; |
| 24101 | |
| 24102 | /* test for int + float */ |
| 24103 | if (verbose) printf("test for int + float"); |
| 24104 | |
| 24105 | cod_assoc_externs(context, externs); |
| 24106 | cod_parse_for_context(extern_string, context); |
| 24107 | |
| 24108 | cod_subroutine_declaration("int proc(int p1, float p2)", |
| 24109 | context); |
| 24110 | gen_code = cod_code_gen(code, context); |
| 24111 | proc = (int (*)(int, float))(long)gen_code->func; |
| 24112 | |
| 24113 | |
| 24114 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 24115 | int source1_i = src1i_vals[i]; |
| 24116 | for (j=0 ; j < sizeof(src2f_vals)/sizeof(src2f_vals[0]) ; j++) { |
| 24117 | float source2_f = src2f_vals[j]; |
| 24118 | double range = 0.000001 * (fabs((double)source1_i) + fabs((double)source2_f)); |
| 24119 | int expected_result; |
| 24120 | int result; |
| 24121 | |
| 24122 | |
| 24123 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 24124 | |
| 24125 | expected_result = (int) (source1_i + source2_f); |
| 24126 | |
| 24127 | result = proc(source1_i, source2_f); |
| 24128 | range += 1.0; |
| 24129 | if ((result > (expected_result + range)) || (result < (expected_result - range))) { |
| 24130 | printf("Failed int + float test, expected %d, got %d, for %d + %g\n", |
| 24131 | expected_result, result, source1_i, source2_f); |
| 24132 | if (dumped == 0) cod_dump(gen_code); |
| 24133 | failed++; |
| 24134 | dumped++; |
| 24135 | } |
| 24136 | } |
| 24137 | } |
| 24138 | if (verbose) printf(" done\n"); |
| 24139 | cod_free_parse_context(context); |
| 24140 | cod_code_free(gen_code); |
| 24141 | } |
| 24142 | if ((only_run_test == NULL((void*)0)) || |
| 24143 | (strcmp(only_run_test, "i+d") == 0)) { |
| 24144 | int i, j; |
| 24145 | static char code[] = "{\n\ |
| 24146 | int a = p1;\n\ |
| 24147 | double b = p2;\n\ |
| 24148 | return a + b;\n\ |
| 24149 | }"; |
| 24150 | |
| 24151 | int (*proc)(int a, double b); |
| 24152 | cod_parse_context context = new_cod_parse_context(); |
| 24153 | int dumped = 0; |
| 24154 | |
| 24155 | cod_code gen_code; |
| 24156 | |
| 24157 | /* test for int + double */ |
| 24158 | if (verbose) printf("test for int + double"); |
| 24159 | |
| 24160 | cod_assoc_externs(context, externs); |
| 24161 | cod_parse_for_context(extern_string, context); |
| 24162 | |
| 24163 | cod_subroutine_declaration("int proc(int p1, double p2)", |
| 24164 | context); |
| 24165 | gen_code = cod_code_gen(code, context); |
| 24166 | proc = (int (*)(int, double))(long)gen_code->func; |
| 24167 | |
| 24168 | |
| 24169 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 24170 | int source1_i = src1i_vals[i]; |
| 24171 | for (j=0 ; j < sizeof(src2d_vals)/sizeof(src2d_vals[0]) ; j++) { |
| 24172 | double source2_d = src2d_vals[j]; |
| 24173 | |
| 24174 | int expected_result; |
| 24175 | int result; |
| 24176 | |
| 24177 | |
| 24178 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 24179 | |
| 24180 | expected_result = (int) (source1_i + source2_d); |
| 24181 | |
| 24182 | result = proc(source1_i, source2_d); |
| 24183 | if (expected_result != result) { |
| 24184 | printf("Failed int + double test, expected %d, got %d, for %d + %g\n", |
| 24185 | expected_result, result, source1_i, source2_d); |
| 24186 | if (dumped == 0) cod_dump(gen_code); |
| 24187 | failed++; |
| 24188 | dumped++; |
| 24189 | } |
| 24190 | } |
| 24191 | } |
| 24192 | if (verbose) printf(" done\n"); |
| 24193 | cod_free_parse_context(context); |
| 24194 | cod_code_free(gen_code); |
| 24195 | } |
| 24196 | } |
| 24197 | void add_u_tests() |
| 24198 | { |
| 24199 | if ((only_run_test == NULL((void*)0)) || |
| 24200 | (strcmp(only_run_test, "u+c") == 0)) { |
| 24201 | int i, j; |
| 24202 | static char code[] = "{\n\ |
| 24203 | unsigned int a = p1;\n\ |
| 24204 | signed char b = p2;\n\ |
| 24205 | return a + b;\n\ |
| 24206 | }"; |
| 24207 | |
| 24208 | unsigned int (*proc)(unsigned int a, signed char b); |
| 24209 | cod_parse_context context = new_cod_parse_context(); |
| 24210 | int dumped = 0; |
| 24211 | |
| 24212 | cod_code gen_code; |
| 24213 | |
| 24214 | /* test for unsigned int + signed char */ |
| 24215 | if (verbose) printf("test for unsigned int + signed char"); |
| 24216 | |
| 24217 | cod_assoc_externs(context, externs); |
| 24218 | cod_parse_for_context(extern_string, context); |
| 24219 | |
| 24220 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, signed char p2)", |
| 24221 | context); |
| 24222 | gen_code = cod_code_gen(code, context); |
| 24223 | proc = (unsigned int (*)(unsigned int, signed char))(long)gen_code->func; |
| 24224 | |
| 24225 | |
| 24226 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 24227 | unsigned int source1_u = src1u_vals[i]; |
| 24228 | for (j=0 ; j < sizeof(src2c_vals)/sizeof(src2c_vals[0]) ; j++) { |
| 24229 | signed char source2_c = src2c_vals[j]; |
| 24230 | |
| 24231 | unsigned int expected_result; |
| 24232 | unsigned int result; |
| 24233 | |
| 24234 | |
| 24235 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 24236 | |
| 24237 | expected_result = (unsigned int) (source1_u + source2_c); |
| 24238 | |
| 24239 | result = proc(source1_u, source2_c); |
| 24240 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 24241 | if (expected_result != result) { |
| 24242 | printf("Failed unsigned int + signed char test, expected %u, got %u, for %u + %d\n", |
| 24243 | expected_result, result, source1_u, source2_c); |
| 24244 | if (dumped == 0) cod_dump(gen_code); |
| 24245 | failed++; |
| 24246 | dumped++; |
| 24247 | } |
| 24248 | } |
| 24249 | } |
| 24250 | if (verbose) printf(" done\n"); |
| 24251 | cod_free_parse_context(context); |
| 24252 | cod_code_free(gen_code); |
| 24253 | } |
| 24254 | if ((only_run_test == NULL((void*)0)) || |
| 24255 | (strcmp(only_run_test, "u+uc") == 0)) { |
| 24256 | int i, j; |
| 24257 | static char code[] = "{\n\ |
| 24258 | unsigned int a = p1;\n\ |
| 24259 | unsigned char b = p2;\n\ |
| 24260 | return a + b;\n\ |
| 24261 | }"; |
| 24262 | |
| 24263 | unsigned int (*proc)(unsigned int a, unsigned char b); |
| 24264 | cod_parse_context context = new_cod_parse_context(); |
| 24265 | int dumped = 0; |
| 24266 | |
| 24267 | cod_code gen_code; |
| 24268 | |
| 24269 | /* test for unsigned int + unsigned char */ |
| 24270 | if (verbose) printf("test for unsigned int + unsigned char"); |
| 24271 | |
| 24272 | cod_assoc_externs(context, externs); |
| 24273 | cod_parse_for_context(extern_string, context); |
| 24274 | |
| 24275 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, unsigned char p2)", |
| 24276 | context); |
| 24277 | gen_code = cod_code_gen(code, context); |
| 24278 | proc = (unsigned int (*)(unsigned int, unsigned char))(long)gen_code->func; |
| 24279 | |
| 24280 | |
| 24281 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 24282 | unsigned int source1_u = src1u_vals[i]; |
| 24283 | for (j=0 ; j < sizeof(src2uc_vals)/sizeof(src2uc_vals[0]) ; j++) { |
| 24284 | unsigned char source2_uc = src2uc_vals[j]; |
| 24285 | |
| 24286 | unsigned int expected_result; |
| 24287 | unsigned int result; |
| 24288 | |
| 24289 | |
| 24290 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 24291 | |
| 24292 | expected_result = (unsigned int) (source1_u + source2_uc); |
| 24293 | |
| 24294 | result = proc(source1_u, source2_uc); |
| 24295 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 24296 | if (expected_result != result) { |
| 24297 | printf("Failed unsigned int + unsigned char test, expected %u, got %u, for %u + %u\n", |
| 24298 | expected_result, result, source1_u, source2_uc); |
| 24299 | if (dumped == 0) cod_dump(gen_code); |
| 24300 | failed++; |
| 24301 | dumped++; |
| 24302 | } |
| 24303 | } |
| 24304 | } |
| 24305 | if (verbose) printf(" done\n"); |
| 24306 | cod_free_parse_context(context); |
| 24307 | cod_code_free(gen_code); |
| 24308 | } |
| 24309 | if ((only_run_test == NULL((void*)0)) || |
| 24310 | (strcmp(only_run_test, "u+s") == 0)) { |
| 24311 | int i, j; |
| 24312 | static char code[] = "{\n\ |
| 24313 | unsigned int a = p1;\n\ |
| 24314 | short b = p2;\n\ |
| 24315 | return a + b;\n\ |
| 24316 | }"; |
| 24317 | |
| 24318 | unsigned int (*proc)(unsigned int a, short b); |
| 24319 | cod_parse_context context = new_cod_parse_context(); |
| 24320 | int dumped = 0; |
| 24321 | |
| 24322 | cod_code gen_code; |
| 24323 | |
| 24324 | /* test for unsigned int + short */ |
| 24325 | if (verbose) printf("test for unsigned int + short"); |
| 24326 | |
| 24327 | cod_assoc_externs(context, externs); |
| 24328 | cod_parse_for_context(extern_string, context); |
| 24329 | |
| 24330 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, short p2)", |
| 24331 | context); |
| 24332 | gen_code = cod_code_gen(code, context); |
| 24333 | proc = (unsigned int (*)(unsigned int, short))(long)gen_code->func; |
| 24334 | |
| 24335 | |
| 24336 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 24337 | unsigned int source1_u = src1u_vals[i]; |
| 24338 | for (j=0 ; j < sizeof(src2s_vals)/sizeof(src2s_vals[0]) ; j++) { |
| 24339 | short source2_s = src2s_vals[j]; |
| 24340 | |
| 24341 | unsigned int expected_result; |
| 24342 | unsigned int result; |
| 24343 | |
| 24344 | |
| 24345 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 24346 | |
| 24347 | expected_result = (unsigned int) (source1_u + source2_s); |
| 24348 | |
| 24349 | result = proc(source1_u, source2_s); |
| 24350 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 24351 | if (expected_result != result) { |
| 24352 | printf("Failed unsigned int + short test, expected %u, got %u, for %u + %d\n", |
| 24353 | expected_result, result, source1_u, source2_s); |
| 24354 | if (dumped == 0) cod_dump(gen_code); |
| 24355 | failed++; |
| 24356 | dumped++; |
| 24357 | } |
| 24358 | } |
| 24359 | } |
| 24360 | if (verbose) printf(" done\n"); |
| 24361 | cod_free_parse_context(context); |
| 24362 | cod_code_free(gen_code); |
| 24363 | } |
| 24364 | if ((only_run_test == NULL((void*)0)) || |
| 24365 | (strcmp(only_run_test, "u+us") == 0)) { |
| 24366 | int i, j; |
| 24367 | static char code[] = "{\n\ |
| 24368 | unsigned int a = p1;\n\ |
| 24369 | unsigned short b = p2;\n\ |
| 24370 | return a + b;\n\ |
| 24371 | }"; |
| 24372 | |
| 24373 | unsigned int (*proc)(unsigned int a, unsigned short b); |
| 24374 | cod_parse_context context = new_cod_parse_context(); |
| 24375 | int dumped = 0; |
| 24376 | |
| 24377 | cod_code gen_code; |
| 24378 | |
| 24379 | /* test for unsigned int + unsigned short */ |
| 24380 | if (verbose) printf("test for unsigned int + unsigned short"); |
| 24381 | |
| 24382 | cod_assoc_externs(context, externs); |
| 24383 | cod_parse_for_context(extern_string, context); |
| 24384 | |
| 24385 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, unsigned short p2)", |
| 24386 | context); |
| 24387 | gen_code = cod_code_gen(code, context); |
| 24388 | proc = (unsigned int (*)(unsigned int, unsigned short))(long)gen_code->func; |
| 24389 | |
| 24390 | |
| 24391 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 24392 | unsigned int source1_u = src1u_vals[i]; |
| 24393 | for (j=0 ; j < sizeof(src2us_vals)/sizeof(src2us_vals[0]) ; j++) { |
| 24394 | unsigned short source2_us = src2us_vals[j]; |
| 24395 | |
| 24396 | unsigned int expected_result; |
| 24397 | unsigned int result; |
| 24398 | |
| 24399 | |
| 24400 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 24401 | |
| 24402 | expected_result = (unsigned int) (source1_u + source2_us); |
| 24403 | |
| 24404 | result = proc(source1_u, source2_us); |
| 24405 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 24406 | if (expected_result != result) { |
| 24407 | printf("Failed unsigned int + unsigned short test, expected %u, got %u, for %u + %u\n", |
| 24408 | expected_result, result, source1_u, source2_us); |
| 24409 | if (dumped == 0) cod_dump(gen_code); |
| 24410 | failed++; |
| 24411 | dumped++; |
| 24412 | } |
| 24413 | } |
| 24414 | } |
| 24415 | if (verbose) printf(" done\n"); |
| 24416 | cod_free_parse_context(context); |
| 24417 | cod_code_free(gen_code); |
| 24418 | } |
| 24419 | if ((only_run_test == NULL((void*)0)) || |
| 24420 | (strcmp(only_run_test, "u+i") == 0)) { |
| 24421 | int i, j; |
| 24422 | static char code[] = "{\n\ |
| 24423 | unsigned int a = p1;\n\ |
| 24424 | int b = p2;\n\ |
| 24425 | return a + b;\n\ |
| 24426 | }"; |
| 24427 | |
| 24428 | unsigned int (*proc)(unsigned int a, int b); |
| 24429 | cod_parse_context context = new_cod_parse_context(); |
| 24430 | int dumped = 0; |
| 24431 | |
| 24432 | cod_code gen_code; |
| 24433 | |
| 24434 | /* test for unsigned int + int */ |
| 24435 | if (verbose) printf("test for unsigned int + int"); |
| 24436 | |
| 24437 | cod_assoc_externs(context, externs); |
| 24438 | cod_parse_for_context(extern_string, context); |
| 24439 | |
| 24440 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, int p2)", |
| 24441 | context); |
| 24442 | gen_code = cod_code_gen(code, context); |
| 24443 | proc = (unsigned int (*)(unsigned int, int))(long)gen_code->func; |
| 24444 | |
| 24445 | |
| 24446 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 24447 | unsigned int source1_u = src1u_vals[i]; |
| 24448 | for (j=0 ; j < sizeof(src2i_vals)/sizeof(src2i_vals[0]) ; j++) { |
| 24449 | int source2_i = src2i_vals[j]; |
| 24450 | |
| 24451 | unsigned int expected_result; |
| 24452 | unsigned int result; |
| 24453 | |
| 24454 | |
| 24455 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 24456 | |
| 24457 | expected_result = (unsigned int) (source1_u + source2_i); |
| 24458 | |
| 24459 | result = proc(source1_u, source2_i); |
| 24460 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 24461 | if (expected_result != result) { |
| 24462 | printf("Failed unsigned int + int test, expected %u, got %u, for %u + %d\n", |
| 24463 | expected_result, result, source1_u, source2_i); |
| 24464 | if (dumped == 0) cod_dump(gen_code); |
| 24465 | failed++; |
| 24466 | dumped++; |
| 24467 | } |
| 24468 | } |
| 24469 | } |
| 24470 | if (verbose) printf(" done\n"); |
| 24471 | cod_free_parse_context(context); |
| 24472 | cod_code_free(gen_code); |
| 24473 | } |
| 24474 | if ((only_run_test == NULL((void*)0)) || |
| 24475 | (strcmp(only_run_test, "u+u") == 0)) { |
| 24476 | int i, j; |
| 24477 | static char code[] = "{\n\ |
| 24478 | unsigned int a = p1;\n\ |
| 24479 | unsigned int b = p2;\n\ |
| 24480 | return a + b;\n\ |
| 24481 | }"; |
| 24482 | |
| 24483 | unsigned int (*proc)(unsigned int a, unsigned int b); |
| 24484 | cod_parse_context context = new_cod_parse_context(); |
| 24485 | int dumped = 0; |
| 24486 | |
| 24487 | cod_code gen_code; |
| 24488 | |
| 24489 | /* test for unsigned int + unsigned int */ |
| 24490 | if (verbose) printf("test for unsigned int + unsigned int"); |
| 24491 | |
| 24492 | cod_assoc_externs(context, externs); |
| 24493 | cod_parse_for_context(extern_string, context); |
| 24494 | |
| 24495 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, unsigned int p2)", |
| 24496 | context); |
| 24497 | gen_code = cod_code_gen(code, context); |
| 24498 | proc = (unsigned int (*)(unsigned int, unsigned int))(long)gen_code->func; |
| 24499 | |
| 24500 | |
| 24501 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 24502 | unsigned int source1_u = src1u_vals[i]; |
| 24503 | for (j=0 ; j < sizeof(src2u_vals)/sizeof(src2u_vals[0]) ; j++) { |
| 24504 | unsigned int source2_u = src2u_vals[j]; |
| 24505 | |
| 24506 | unsigned int expected_result; |
| 24507 | unsigned int result; |
| 24508 | |
| 24509 | |
| 24510 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 24511 | |
| 24512 | expected_result = (unsigned int) (source1_u + source2_u); |
| 24513 | |
| 24514 | result = proc(source1_u, source2_u); |
| 24515 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 24516 | if (expected_result != result) { |
| 24517 | printf("Failed unsigned int + unsigned int test, expected %u, got %u, for %u + %u\n", |
| 24518 | expected_result, result, source1_u, source2_u); |
| 24519 | if (dumped == 0) cod_dump(gen_code); |
| 24520 | failed++; |
| 24521 | dumped++; |
| 24522 | } |
| 24523 | } |
| 24524 | } |
| 24525 | if (verbose) printf(" done\n"); |
| 24526 | cod_free_parse_context(context); |
| 24527 | cod_code_free(gen_code); |
| 24528 | } |
| 24529 | if ((only_run_test == NULL((void*)0)) || |
| 24530 | (strcmp(only_run_test, "u+ul") == 0)) { |
| 24531 | int i, j; |
| 24532 | static char code[] = "{\n\ |
| 24533 | unsigned int a = p1;\n\ |
| 24534 | unsigned long b = p2;\n\ |
| 24535 | return a + b;\n\ |
| 24536 | }"; |
| 24537 | |
| 24538 | unsigned int (*proc)(unsigned int a, unsigned long b); |
| 24539 | cod_parse_context context = new_cod_parse_context(); |
| 24540 | int dumped = 0; |
| 24541 | |
| 24542 | cod_code gen_code; |
| 24543 | |
| 24544 | /* test for unsigned int + unsigned long */ |
| 24545 | if (verbose) printf("test for unsigned int + unsigned long"); |
| 24546 | |
| 24547 | cod_assoc_externs(context, externs); |
| 24548 | cod_parse_for_context(extern_string, context); |
| 24549 | |
| 24550 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, unsigned long p2)", |
| 24551 | context); |
| 24552 | gen_code = cod_code_gen(code, context); |
| 24553 | proc = (unsigned int (*)(unsigned int, unsigned long))(long)gen_code->func; |
| 24554 | |
| 24555 | |
| 24556 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 24557 | unsigned int source1_u = src1u_vals[i]; |
| 24558 | for (j=0 ; j < sizeof(src2ul_vals)/sizeof(src2ul_vals[0]) ; j++) { |
| 24559 | unsigned long source2_ul = src2ul_vals[j]; |
| 24560 | |
| 24561 | unsigned int expected_result; |
| 24562 | unsigned int result; |
| 24563 | |
| 24564 | |
| 24565 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 24566 | |
| 24567 | expected_result = (unsigned int) (source1_u + source2_ul); |
| 24568 | |
| 24569 | result = proc(source1_u, source2_ul); |
| 24570 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 24571 | if (expected_result != result) { |
| 24572 | printf("Failed unsigned int + unsigned long test, expected %u, got %u, for %u + %lu\n", |
| 24573 | expected_result, result, source1_u, source2_ul); |
| 24574 | if (dumped == 0) cod_dump(gen_code); |
| 24575 | failed++; |
| 24576 | dumped++; |
| 24577 | } |
| 24578 | } |
| 24579 | } |
| 24580 | if (verbose) printf(" done\n"); |
| 24581 | cod_free_parse_context(context); |
| 24582 | cod_code_free(gen_code); |
| 24583 | } |
| 24584 | if ((only_run_test == NULL((void*)0)) || |
| 24585 | (strcmp(only_run_test, "u+l") == 0)) { |
| 24586 | int i, j; |
| 24587 | static char code[] = "{\n\ |
| 24588 | unsigned int a = p1;\n\ |
| 24589 | long b = p2;\n\ |
| 24590 | return a + b;\n\ |
| 24591 | }"; |
| 24592 | |
| 24593 | unsigned int (*proc)(unsigned int a, long b); |
| 24594 | cod_parse_context context = new_cod_parse_context(); |
| 24595 | int dumped = 0; |
| 24596 | |
| 24597 | cod_code gen_code; |
| 24598 | |
| 24599 | /* test for unsigned int + long */ |
| 24600 | if (verbose) printf("test for unsigned int + long"); |
| 24601 | |
| 24602 | cod_assoc_externs(context, externs); |
| 24603 | cod_parse_for_context(extern_string, context); |
| 24604 | |
| 24605 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, long p2)", |
| 24606 | context); |
| 24607 | gen_code = cod_code_gen(code, context); |
| 24608 | proc = (unsigned int (*)(unsigned int, long))(long)gen_code->func; |
| 24609 | |
| 24610 | |
| 24611 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 24612 | unsigned int source1_u = src1u_vals[i]; |
| 24613 | for (j=0 ; j < sizeof(src2l_vals)/sizeof(src2l_vals[0]) ; j++) { |
| 24614 | long source2_l = src2l_vals[j]; |
| 24615 | |
| 24616 | unsigned int expected_result; |
| 24617 | unsigned int result; |
| 24618 | |
| 24619 | |
| 24620 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 24621 | |
| 24622 | expected_result = (unsigned int) (source1_u + source2_l); |
| 24623 | |
| 24624 | result = proc(source1_u, source2_l); |
| 24625 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 24626 | if (expected_result != result) { |
| 24627 | printf("Failed unsigned int + long test, expected %u, got %u, for %u + %ld\n", |
| 24628 | expected_result, result, source1_u, source2_l); |
| 24629 | if (dumped == 0) cod_dump(gen_code); |
| 24630 | failed++; |
| 24631 | dumped++; |
| 24632 | } |
| 24633 | } |
| 24634 | } |
| 24635 | if (verbose) printf(" done\n"); |
| 24636 | cod_free_parse_context(context); |
| 24637 | cod_code_free(gen_code); |
| 24638 | } |
| 24639 | if ((only_run_test == NULL((void*)0)) || |
| 24640 | (strcmp(only_run_test, "u+f") == 0)) { |
| 24641 | int i, j; |
| 24642 | static char code[] = "{\n\ |
| 24643 | unsigned int a = p1;\n\ |
| 24644 | float b = p2;\n\ |
| 24645 | return a + b;\n\ |
| 24646 | }"; |
| 24647 | |
| 24648 | unsigned int (*proc)(unsigned int a, float b); |
| 24649 | cod_parse_context context = new_cod_parse_context(); |
| 24650 | int dumped = 0; |
| 24651 | |
| 24652 | cod_code gen_code; |
| 24653 | |
| 24654 | /* test for unsigned int + float */ |
| 24655 | if (verbose) printf("test for unsigned int + float"); |
| 24656 | |
| 24657 | cod_assoc_externs(context, externs); |
| 24658 | cod_parse_for_context(extern_string, context); |
| 24659 | |
| 24660 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, float p2)", |
| 24661 | context); |
| 24662 | gen_code = cod_code_gen(code, context); |
| 24663 | proc = (unsigned int (*)(unsigned int, float))(long)gen_code->func; |
| 24664 | |
| 24665 | |
| 24666 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 24667 | unsigned int source1_u = src1u_vals[i]; |
| 24668 | for (j=0 ; j < sizeof(src2f_vals)/sizeof(src2f_vals[0]) ; j++) { |
| 24669 | float source2_f = src2f_vals[j]; |
| 24670 | double range = 0.000001 * (fabs((double)source1_u) + fabs((double)source2_f)); |
| 24671 | unsigned int expected_result; |
| 24672 | unsigned int result; |
| 24673 | |
| 24674 | |
| 24675 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 24676 | |
| 24677 | expected_result = (unsigned int) (source1_u + source2_f); |
| 24678 | |
| 24679 | result = proc(source1_u, source2_f); |
| 24680 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 24681 | range += 1.0; |
| 24682 | if ((result > (expected_result + range)) || (result < (expected_result - range))) { |
| 24683 | printf("Failed unsigned int + float test, expected %u, got %u, for %u + %g\n", |
| 24684 | expected_result, result, source1_u, source2_f); |
| 24685 | if (dumped == 0) cod_dump(gen_code); |
| 24686 | failed++; |
| 24687 | dumped++; |
| 24688 | } |
| 24689 | } |
| 24690 | } |
| 24691 | if (verbose) printf(" done\n"); |
| 24692 | cod_free_parse_context(context); |
| 24693 | cod_code_free(gen_code); |
| 24694 | } |
| 24695 | if ((only_run_test == NULL((void*)0)) || |
| 24696 | (strcmp(only_run_test, "u+d") == 0)) { |
| 24697 | int i, j; |
| 24698 | static char code[] = "{\n\ |
| 24699 | unsigned int a = p1;\n\ |
| 24700 | double b = p2;\n\ |
| 24701 | return a + b;\n\ |
| 24702 | }"; |
| 24703 | |
| 24704 | unsigned int (*proc)(unsigned int a, double b); |
| 24705 | cod_parse_context context = new_cod_parse_context(); |
| 24706 | int dumped = 0; |
| 24707 | |
| 24708 | cod_code gen_code; |
| 24709 | |
| 24710 | /* test for unsigned int + double */ |
| 24711 | if (verbose) printf("test for unsigned int + double"); |
| 24712 | |
| 24713 | cod_assoc_externs(context, externs); |
| 24714 | cod_parse_for_context(extern_string, context); |
| 24715 | |
| 24716 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, double p2)", |
| 24717 | context); |
| 24718 | gen_code = cod_code_gen(code, context); |
| 24719 | proc = (unsigned int (*)(unsigned int, double))(long)gen_code->func; |
| 24720 | |
| 24721 | |
| 24722 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 24723 | unsigned int source1_u = src1u_vals[i]; |
| 24724 | for (j=0 ; j < sizeof(src2d_vals)/sizeof(src2d_vals[0]) ; j++) { |
| 24725 | double source2_d = src2d_vals[j]; |
| 24726 | |
| 24727 | unsigned int expected_result; |
| 24728 | unsigned int result; |
| 24729 | |
| 24730 | |
| 24731 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 24732 | |
| 24733 | expected_result = (unsigned int) (source1_u + source2_d); |
| 24734 | |
| 24735 | result = proc(source1_u, source2_d); |
| 24736 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 24737 | if (expected_result != result) { |
| 24738 | printf("Failed unsigned int + double test, expected %u, got %u, for %u + %g\n", |
| 24739 | expected_result, result, source1_u, source2_d); |
| 24740 | if (dumped == 0) cod_dump(gen_code); |
| 24741 | failed++; |
| 24742 | dumped++; |
| 24743 | } |
| 24744 | } |
| 24745 | } |
| 24746 | if (verbose) printf(" done\n"); |
| 24747 | cod_free_parse_context(context); |
| 24748 | cod_code_free(gen_code); |
| 24749 | } |
| 24750 | } |
| 24751 | void add_ul_tests() |
| 24752 | { |
| 24753 | if ((only_run_test == NULL((void*)0)) || |
| 24754 | (strcmp(only_run_test, "ul+c") == 0)) { |
| 24755 | int i, j; |
| 24756 | static char code[] = "{\n\ |
| 24757 | unsigned long a = p1;\n\ |
| 24758 | signed char b = p2;\n\ |
| 24759 | return a + b;\n\ |
| 24760 | }"; |
| 24761 | |
| 24762 | unsigned long (*proc)(unsigned long a, signed char b); |
| 24763 | cod_parse_context context = new_cod_parse_context(); |
| 24764 | int dumped = 0; |
| 24765 | |
| 24766 | cod_code gen_code; |
| 24767 | |
| 24768 | /* test for unsigned long + signed char */ |
| 24769 | if (verbose) printf("test for unsigned long + signed char"); |
| 24770 | |
| 24771 | cod_assoc_externs(context, externs); |
| 24772 | cod_parse_for_context(extern_string, context); |
| 24773 | |
| 24774 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, signed char p2)", |
| 24775 | context); |
| 24776 | gen_code = cod_code_gen(code, context); |
| 24777 | proc = (unsigned long (*)(unsigned long, signed char))(long)gen_code->func; |
| 24778 | |
| 24779 | |
| 24780 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 24781 | unsigned long source1_ul = src1ul_vals[i]; |
| 24782 | for (j=0 ; j < sizeof(src2c_vals)/sizeof(src2c_vals[0]) ; j++) { |
| 24783 | signed char source2_c = src2c_vals[j]; |
| 24784 | |
| 24785 | unsigned long expected_result; |
| 24786 | unsigned long result; |
| 24787 | |
| 24788 | |
| 24789 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 24790 | |
| 24791 | expected_result = (unsigned long) (source1_ul + source2_c); |
| 24792 | |
| 24793 | result = proc(source1_ul, source2_c); |
| 24794 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 24795 | if (expected_result != result) { |
| 24796 | printf("Failed unsigned long + signed char test, expected %lu, got %lu, for %lu + %d\n", |
| 24797 | expected_result, result, source1_ul, source2_c); |
| 24798 | if (dumped == 0) cod_dump(gen_code); |
| 24799 | failed++; |
| 24800 | dumped++; |
| 24801 | } |
| 24802 | } |
| 24803 | } |
| 24804 | if (verbose) printf(" done\n"); |
| 24805 | cod_free_parse_context(context); |
| 24806 | cod_code_free(gen_code); |
| 24807 | } |
| 24808 | if ((only_run_test == NULL((void*)0)) || |
| 24809 | (strcmp(only_run_test, "ul+uc") == 0)) { |
| 24810 | int i, j; |
| 24811 | static char code[] = "{\n\ |
| 24812 | unsigned long a = p1;\n\ |
| 24813 | unsigned char b = p2;\n\ |
| 24814 | return a + b;\n\ |
| 24815 | }"; |
| 24816 | |
| 24817 | unsigned long (*proc)(unsigned long a, unsigned char b); |
| 24818 | cod_parse_context context = new_cod_parse_context(); |
| 24819 | int dumped = 0; |
| 24820 | |
| 24821 | cod_code gen_code; |
| 24822 | |
| 24823 | /* test for unsigned long + unsigned char */ |
| 24824 | if (verbose) printf("test for unsigned long + unsigned char"); |
| 24825 | |
| 24826 | cod_assoc_externs(context, externs); |
| 24827 | cod_parse_for_context(extern_string, context); |
| 24828 | |
| 24829 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, unsigned char p2)", |
| 24830 | context); |
| 24831 | gen_code = cod_code_gen(code, context); |
| 24832 | proc = (unsigned long (*)(unsigned long, unsigned char))(long)gen_code->func; |
| 24833 | |
| 24834 | |
| 24835 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 24836 | unsigned long source1_ul = src1ul_vals[i]; |
| 24837 | for (j=0 ; j < sizeof(src2uc_vals)/sizeof(src2uc_vals[0]) ; j++) { |
| 24838 | unsigned char source2_uc = src2uc_vals[j]; |
| 24839 | |
| 24840 | unsigned long expected_result; |
| 24841 | unsigned long result; |
| 24842 | |
| 24843 | |
| 24844 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 24845 | |
| 24846 | expected_result = (unsigned long) (source1_ul + source2_uc); |
| 24847 | |
| 24848 | result = proc(source1_ul, source2_uc); |
| 24849 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 24850 | if (expected_result != result) { |
| 24851 | printf("Failed unsigned long + unsigned char test, expected %lu, got %lu, for %lu + %u\n", |
| 24852 | expected_result, result, source1_ul, source2_uc); |
| 24853 | if (dumped == 0) cod_dump(gen_code); |
| 24854 | failed++; |
| 24855 | dumped++; |
| 24856 | } |
| 24857 | } |
| 24858 | } |
| 24859 | if (verbose) printf(" done\n"); |
| 24860 | cod_free_parse_context(context); |
| 24861 | cod_code_free(gen_code); |
| 24862 | } |
| 24863 | if ((only_run_test == NULL((void*)0)) || |
| 24864 | (strcmp(only_run_test, "ul+s") == 0)) { |
| 24865 | int i, j; |
| 24866 | static char code[] = "{\n\ |
| 24867 | unsigned long a = p1;\n\ |
| 24868 | short b = p2;\n\ |
| 24869 | return a + b;\n\ |
| 24870 | }"; |
| 24871 | |
| 24872 | unsigned long (*proc)(unsigned long a, short b); |
| 24873 | cod_parse_context context = new_cod_parse_context(); |
| 24874 | int dumped = 0; |
| 24875 | |
| 24876 | cod_code gen_code; |
| 24877 | |
| 24878 | /* test for unsigned long + short */ |
| 24879 | if (verbose) printf("test for unsigned long + short"); |
| 24880 | |
| 24881 | cod_assoc_externs(context, externs); |
| 24882 | cod_parse_for_context(extern_string, context); |
| 24883 | |
| 24884 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, short p2)", |
| 24885 | context); |
| 24886 | gen_code = cod_code_gen(code, context); |
| 24887 | proc = (unsigned long (*)(unsigned long, short))(long)gen_code->func; |
| 24888 | |
| 24889 | |
| 24890 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 24891 | unsigned long source1_ul = src1ul_vals[i]; |
| 24892 | for (j=0 ; j < sizeof(src2s_vals)/sizeof(src2s_vals[0]) ; j++) { |
| 24893 | short source2_s = src2s_vals[j]; |
| 24894 | |
| 24895 | unsigned long expected_result; |
| 24896 | unsigned long result; |
| 24897 | |
| 24898 | |
| 24899 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 24900 | |
| 24901 | expected_result = (unsigned long) (source1_ul + source2_s); |
| 24902 | |
| 24903 | result = proc(source1_ul, source2_s); |
| 24904 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 24905 | if (expected_result != result) { |
| 24906 | printf("Failed unsigned long + short test, expected %lu, got %lu, for %lu + %d\n", |
| 24907 | expected_result, result, source1_ul, source2_s); |
| 24908 | if (dumped == 0) cod_dump(gen_code); |
| 24909 | failed++; |
| 24910 | dumped++; |
| 24911 | } |
| 24912 | } |
| 24913 | } |
| 24914 | if (verbose) printf(" done\n"); |
| 24915 | cod_free_parse_context(context); |
| 24916 | cod_code_free(gen_code); |
| 24917 | } |
| 24918 | if ((only_run_test == NULL((void*)0)) || |
| 24919 | (strcmp(only_run_test, "ul+us") == 0)) { |
| 24920 | int i, j; |
| 24921 | static char code[] = "{\n\ |
| 24922 | unsigned long a = p1;\n\ |
| 24923 | unsigned short b = p2;\n\ |
| 24924 | return a + b;\n\ |
| 24925 | }"; |
| 24926 | |
| 24927 | unsigned long (*proc)(unsigned long a, unsigned short b); |
| 24928 | cod_parse_context context = new_cod_parse_context(); |
| 24929 | int dumped = 0; |
| 24930 | |
| 24931 | cod_code gen_code; |
| 24932 | |
| 24933 | /* test for unsigned long + unsigned short */ |
| 24934 | if (verbose) printf("test for unsigned long + unsigned short"); |
| 24935 | |
| 24936 | cod_assoc_externs(context, externs); |
| 24937 | cod_parse_for_context(extern_string, context); |
| 24938 | |
| 24939 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, unsigned short p2)", |
| 24940 | context); |
| 24941 | gen_code = cod_code_gen(code, context); |
| 24942 | proc = (unsigned long (*)(unsigned long, unsigned short))(long)gen_code->func; |
| 24943 | |
| 24944 | |
| 24945 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 24946 | unsigned long source1_ul = src1ul_vals[i]; |
| 24947 | for (j=0 ; j < sizeof(src2us_vals)/sizeof(src2us_vals[0]) ; j++) { |
| 24948 | unsigned short source2_us = src2us_vals[j]; |
| 24949 | |
| 24950 | unsigned long expected_result; |
| 24951 | unsigned long result; |
| 24952 | |
| 24953 | |
| 24954 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 24955 | |
| 24956 | expected_result = (unsigned long) (source1_ul + source2_us); |
| 24957 | |
| 24958 | result = proc(source1_ul, source2_us); |
| 24959 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 24960 | if (expected_result != result) { |
| 24961 | printf("Failed unsigned long + unsigned short test, expected %lu, got %lu, for %lu + %u\n", |
| 24962 | expected_result, result, source1_ul, source2_us); |
| 24963 | if (dumped == 0) cod_dump(gen_code); |
| 24964 | failed++; |
| 24965 | dumped++; |
| 24966 | } |
| 24967 | } |
| 24968 | } |
| 24969 | if (verbose) printf(" done\n"); |
| 24970 | cod_free_parse_context(context); |
| 24971 | cod_code_free(gen_code); |
| 24972 | } |
| 24973 | if ((only_run_test == NULL((void*)0)) || |
| 24974 | (strcmp(only_run_test, "ul+i") == 0)) { |
| 24975 | int i, j; |
| 24976 | static char code[] = "{\n\ |
| 24977 | unsigned long a = p1;\n\ |
| 24978 | int b = p2;\n\ |
| 24979 | return a + b;\n\ |
| 24980 | }"; |
| 24981 | |
| 24982 | unsigned long (*proc)(unsigned long a, int b); |
| 24983 | cod_parse_context context = new_cod_parse_context(); |
| 24984 | int dumped = 0; |
| 24985 | |
| 24986 | cod_code gen_code; |
| 24987 | |
| 24988 | /* test for unsigned long + int */ |
| 24989 | if (verbose) printf("test for unsigned long + int"); |
| 24990 | |
| 24991 | cod_assoc_externs(context, externs); |
| 24992 | cod_parse_for_context(extern_string, context); |
| 24993 | |
| 24994 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, int p2)", |
| 24995 | context); |
| 24996 | gen_code = cod_code_gen(code, context); |
| 24997 | proc = (unsigned long (*)(unsigned long, int))(long)gen_code->func; |
| 24998 | |
| 24999 | |
| 25000 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 25001 | unsigned long source1_ul = src1ul_vals[i]; |
| 25002 | for (j=0 ; j < sizeof(src2i_vals)/sizeof(src2i_vals[0]) ; j++) { |
| 25003 | int source2_i = src2i_vals[j]; |
| 25004 | |
| 25005 | unsigned long expected_result; |
| 25006 | unsigned long result; |
| 25007 | |
| 25008 | |
| 25009 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 25010 | |
| 25011 | expected_result = (unsigned long) (source1_ul + source2_i); |
| 25012 | |
| 25013 | result = proc(source1_ul, source2_i); |
| 25014 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 25015 | if (expected_result != result) { |
| 25016 | printf("Failed unsigned long + int test, expected %lu, got %lu, for %lu + %d\n", |
| 25017 | expected_result, result, source1_ul, source2_i); |
| 25018 | if (dumped == 0) cod_dump(gen_code); |
| 25019 | failed++; |
| 25020 | dumped++; |
| 25021 | } |
| 25022 | } |
| 25023 | } |
| 25024 | if (verbose) printf(" done\n"); |
| 25025 | cod_free_parse_context(context); |
| 25026 | cod_code_free(gen_code); |
| 25027 | } |
| 25028 | if ((only_run_test == NULL((void*)0)) || |
| 25029 | (strcmp(only_run_test, "ul+u") == 0)) { |
| 25030 | int i, j; |
| 25031 | static char code[] = "{\n\ |
| 25032 | unsigned long a = p1;\n\ |
| 25033 | unsigned int b = p2;\n\ |
| 25034 | return a + b;\n\ |
| 25035 | }"; |
| 25036 | |
| 25037 | unsigned long (*proc)(unsigned long a, unsigned int b); |
| 25038 | cod_parse_context context = new_cod_parse_context(); |
| 25039 | int dumped = 0; |
| 25040 | |
| 25041 | cod_code gen_code; |
| 25042 | |
| 25043 | /* test for unsigned long + unsigned int */ |
| 25044 | if (verbose) printf("test for unsigned long + unsigned int"); |
| 25045 | |
| 25046 | cod_assoc_externs(context, externs); |
| 25047 | cod_parse_for_context(extern_string, context); |
| 25048 | |
| 25049 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, unsigned int p2)", |
| 25050 | context); |
| 25051 | gen_code = cod_code_gen(code, context); |
| 25052 | proc = (unsigned long (*)(unsigned long, unsigned int))(long)gen_code->func; |
| 25053 | |
| 25054 | |
| 25055 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 25056 | unsigned long source1_ul = src1ul_vals[i]; |
| 25057 | for (j=0 ; j < sizeof(src2u_vals)/sizeof(src2u_vals[0]) ; j++) { |
| 25058 | unsigned int source2_u = src2u_vals[j]; |
| 25059 | |
| 25060 | unsigned long expected_result; |
| 25061 | unsigned long result; |
| 25062 | |
| 25063 | |
| 25064 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 25065 | |
| 25066 | expected_result = (unsigned long) (source1_ul + source2_u); |
| 25067 | |
| 25068 | result = proc(source1_ul, source2_u); |
| 25069 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 25070 | if (expected_result != result) { |
| 25071 | printf("Failed unsigned long + unsigned int test, expected %lu, got %lu, for %lu + %u\n", |
| 25072 | expected_result, result, source1_ul, source2_u); |
| 25073 | if (dumped == 0) cod_dump(gen_code); |
| 25074 | failed++; |
| 25075 | dumped++; |
| 25076 | } |
| 25077 | } |
| 25078 | } |
| 25079 | if (verbose) printf(" done\n"); |
| 25080 | cod_free_parse_context(context); |
| 25081 | cod_code_free(gen_code); |
| 25082 | } |
| 25083 | if ((only_run_test == NULL((void*)0)) || |
| 25084 | (strcmp(only_run_test, "ul+ul") == 0)) { |
| 25085 | int i, j; |
| 25086 | static char code[] = "{\n\ |
| 25087 | unsigned long a = p1;\n\ |
| 25088 | unsigned long b = p2;\n\ |
| 25089 | return a + b;\n\ |
| 25090 | }"; |
| 25091 | |
| 25092 | unsigned long (*proc)(unsigned long a, unsigned long b); |
| 25093 | cod_parse_context context = new_cod_parse_context(); |
| 25094 | int dumped = 0; |
| 25095 | |
| 25096 | cod_code gen_code; |
| 25097 | |
| 25098 | /* test for unsigned long + unsigned long */ |
| 25099 | if (verbose) printf("test for unsigned long + unsigned long"); |
| 25100 | |
| 25101 | cod_assoc_externs(context, externs); |
| 25102 | cod_parse_for_context(extern_string, context); |
| 25103 | |
| 25104 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, unsigned long p2)", |
| 25105 | context); |
| 25106 | gen_code = cod_code_gen(code, context); |
| 25107 | proc = (unsigned long (*)(unsigned long, unsigned long))(long)gen_code->func; |
| 25108 | |
| 25109 | |
| 25110 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 25111 | unsigned long source1_ul = src1ul_vals[i]; |
| 25112 | for (j=0 ; j < sizeof(src2ul_vals)/sizeof(src2ul_vals[0]) ; j++) { |
| 25113 | unsigned long source2_ul = src2ul_vals[j]; |
| 25114 | |
| 25115 | unsigned long expected_result; |
| 25116 | unsigned long result; |
| 25117 | |
| 25118 | |
| 25119 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 25120 | |
| 25121 | expected_result = (unsigned long) (source1_ul + source2_ul); |
| 25122 | |
| 25123 | result = proc(source1_ul, source2_ul); |
| 25124 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 25125 | if (expected_result != result) { |
| 25126 | printf("Failed unsigned long + unsigned long test, expected %lu, got %lu, for %lu + %lu\n", |
| 25127 | expected_result, result, source1_ul, source2_ul); |
| 25128 | if (dumped == 0) cod_dump(gen_code); |
| 25129 | failed++; |
| 25130 | dumped++; |
| 25131 | } |
| 25132 | } |
| 25133 | } |
| 25134 | if (verbose) printf(" done\n"); |
| 25135 | cod_free_parse_context(context); |
| 25136 | cod_code_free(gen_code); |
| 25137 | } |
| 25138 | if ((only_run_test == NULL((void*)0)) || |
| 25139 | (strcmp(only_run_test, "ul+l") == 0)) { |
| 25140 | int i, j; |
| 25141 | static char code[] = "{\n\ |
| 25142 | unsigned long a = p1;\n\ |
| 25143 | long b = p2;\n\ |
| 25144 | return a + b;\n\ |
| 25145 | }"; |
| 25146 | |
| 25147 | unsigned long (*proc)(unsigned long a, long b); |
| 25148 | cod_parse_context context = new_cod_parse_context(); |
| 25149 | int dumped = 0; |
| 25150 | |
| 25151 | cod_code gen_code; |
| 25152 | |
| 25153 | /* test for unsigned long + long */ |
| 25154 | if (verbose) printf("test for unsigned long + long"); |
| 25155 | |
| 25156 | cod_assoc_externs(context, externs); |
| 25157 | cod_parse_for_context(extern_string, context); |
| 25158 | |
| 25159 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, long p2)", |
| 25160 | context); |
| 25161 | gen_code = cod_code_gen(code, context); |
| 25162 | proc = (unsigned long (*)(unsigned long, long))(long)gen_code->func; |
| 25163 | |
| 25164 | |
| 25165 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 25166 | unsigned long source1_ul = src1ul_vals[i]; |
| 25167 | for (j=0 ; j < sizeof(src2l_vals)/sizeof(src2l_vals[0]) ; j++) { |
| 25168 | long source2_l = src2l_vals[j]; |
| 25169 | |
| 25170 | unsigned long expected_result; |
| 25171 | unsigned long result; |
| 25172 | |
| 25173 | |
| 25174 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 25175 | |
| 25176 | expected_result = (unsigned long) (source1_ul + source2_l); |
| 25177 | |
| 25178 | result = proc(source1_ul, source2_l); |
| 25179 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 25180 | if (expected_result != result) { |
| 25181 | printf("Failed unsigned long + long test, expected %lu, got %lu, for %lu + %ld\n", |
| 25182 | expected_result, result, source1_ul, source2_l); |
| 25183 | if (dumped == 0) cod_dump(gen_code); |
| 25184 | failed++; |
| 25185 | dumped++; |
| 25186 | } |
| 25187 | } |
| 25188 | } |
| 25189 | if (verbose) printf(" done\n"); |
| 25190 | cod_free_parse_context(context); |
| 25191 | cod_code_free(gen_code); |
| 25192 | } |
| 25193 | if ((only_run_test == NULL((void*)0)) || |
| 25194 | (strcmp(only_run_test, "ul+f") == 0)) { |
| 25195 | int i, j; |
| 25196 | static char code[] = "{\n\ |
| 25197 | unsigned long a = p1;\n\ |
| 25198 | float b = p2;\n\ |
| 25199 | return a + b;\n\ |
| 25200 | }"; |
| 25201 | |
| 25202 | unsigned long (*proc)(unsigned long a, float b); |
| 25203 | cod_parse_context context = new_cod_parse_context(); |
| 25204 | int dumped = 0; |
| 25205 | |
| 25206 | cod_code gen_code; |
| 25207 | |
| 25208 | /* test for unsigned long + float */ |
| 25209 | if (verbose) printf("test for unsigned long + float"); |
| 25210 | |
| 25211 | cod_assoc_externs(context, externs); |
| 25212 | cod_parse_for_context(extern_string, context); |
| 25213 | |
| 25214 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, float p2)", |
| 25215 | context); |
| 25216 | gen_code = cod_code_gen(code, context); |
| 25217 | proc = (unsigned long (*)(unsigned long, float))(long)gen_code->func; |
| 25218 | |
| 25219 | |
| 25220 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 25221 | unsigned long source1_ul = src1ul_vals[i]; |
| 25222 | for (j=0 ; j < sizeof(src2f_vals)/sizeof(src2f_vals[0]) ; j++) { |
| 25223 | float source2_f = src2f_vals[j]; |
| 25224 | double range = 0.000001 * (fabs((double)source1_ul) + fabs((double)source2_f)); |
| 25225 | unsigned long expected_result; |
| 25226 | unsigned long result; |
| 25227 | |
| 25228 | |
| 25229 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 25230 | |
| 25231 | expected_result = (unsigned long) (source1_ul + source2_f); |
| 25232 | |
| 25233 | result = proc(source1_ul, source2_f); |
| 25234 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 25235 | range += 1.0; |
| 25236 | if ((result > (expected_result + range)) || (result < (expected_result - range))) { |
| 25237 | printf("Failed unsigned long + float test, expected %lu, got %lu, for %lu + %g\n", |
| 25238 | expected_result, result, source1_ul, source2_f); |
| 25239 | if (dumped == 0) cod_dump(gen_code); |
| 25240 | failed++; |
| 25241 | dumped++; |
| 25242 | } |
| 25243 | } |
| 25244 | } |
| 25245 | if (verbose) printf(" done\n"); |
| 25246 | cod_free_parse_context(context); |
| 25247 | cod_code_free(gen_code); |
| 25248 | } |
| 25249 | if ((only_run_test == NULL((void*)0)) || |
| 25250 | (strcmp(only_run_test, "ul+d") == 0)) { |
| 25251 | int i, j; |
| 25252 | static char code[] = "{\n\ |
| 25253 | unsigned long a = p1;\n\ |
| 25254 | double b = p2;\n\ |
| 25255 | return a + b;\n\ |
| 25256 | }"; |
| 25257 | |
| 25258 | unsigned long (*proc)(unsigned long a, double b); |
| 25259 | cod_parse_context context = new_cod_parse_context(); |
| 25260 | int dumped = 0; |
| 25261 | |
| 25262 | cod_code gen_code; |
| 25263 | |
| 25264 | /* test for unsigned long + double */ |
| 25265 | if (verbose) printf("test for unsigned long + double"); |
| 25266 | |
| 25267 | cod_assoc_externs(context, externs); |
| 25268 | cod_parse_for_context(extern_string, context); |
| 25269 | |
| 25270 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, double p2)", |
| 25271 | context); |
| 25272 | gen_code = cod_code_gen(code, context); |
| 25273 | proc = (unsigned long (*)(unsigned long, double))(long)gen_code->func; |
| 25274 | |
| 25275 | |
| 25276 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 25277 | unsigned long source1_ul = src1ul_vals[i]; |
| 25278 | for (j=0 ; j < sizeof(src2d_vals)/sizeof(src2d_vals[0]) ; j++) { |
| 25279 | double source2_d = src2d_vals[j]; |
| 25280 | |
| 25281 | unsigned long expected_result; |
| 25282 | unsigned long result; |
| 25283 | |
| 25284 | |
| 25285 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 25286 | |
| 25287 | expected_result = (unsigned long) (source1_ul + source2_d); |
| 25288 | |
| 25289 | result = proc(source1_ul, source2_d); |
| 25290 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 25291 | if (expected_result != result) { |
| 25292 | printf("Failed unsigned long + double test, expected %lu, got %lu, for %lu + %g\n", |
| 25293 | expected_result, result, source1_ul, source2_d); |
| 25294 | if (dumped == 0) cod_dump(gen_code); |
| 25295 | failed++; |
| 25296 | dumped++; |
| 25297 | } |
| 25298 | } |
| 25299 | } |
| 25300 | if (verbose) printf(" done\n"); |
| 25301 | cod_free_parse_context(context); |
| 25302 | cod_code_free(gen_code); |
| 25303 | } |
| 25304 | } |
| 25305 | void add_l_tests() |
| 25306 | { |
| 25307 | if ((only_run_test == NULL((void*)0)) || |
| 25308 | (strcmp(only_run_test, "l+c") == 0)) { |
| 25309 | int i, j; |
| 25310 | static char code[] = "{\n\ |
| 25311 | long a = p1;\n\ |
| 25312 | signed char b = p2;\n\ |
| 25313 | return a + b;\n\ |
| 25314 | }"; |
| 25315 | |
| 25316 | long (*proc)(long a, signed char b); |
| 25317 | cod_parse_context context = new_cod_parse_context(); |
| 25318 | int dumped = 0; |
| 25319 | |
| 25320 | cod_code gen_code; |
| 25321 | |
| 25322 | /* test for long + signed char */ |
| 25323 | if (verbose) printf("test for long + signed char"); |
| 25324 | |
| 25325 | cod_assoc_externs(context, externs); |
| 25326 | cod_parse_for_context(extern_string, context); |
| 25327 | |
| 25328 | cod_subroutine_declaration("long proc(long p1, signed char p2)", |
| 25329 | context); |
| 25330 | gen_code = cod_code_gen(code, context); |
| 25331 | proc = (long (*)(long, signed char))(long)gen_code->func; |
| 25332 | |
| 25333 | |
| 25334 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 25335 | long source1_l = src1l_vals[i]; |
| 25336 | for (j=0 ; j < sizeof(src2c_vals)/sizeof(src2c_vals[0]) ; j++) { |
| 25337 | signed char source2_c = src2c_vals[j]; |
| 25338 | |
| 25339 | long expected_result; |
| 25340 | long result; |
| 25341 | |
| 25342 | |
| 25343 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 25344 | |
| 25345 | expected_result = (long) (source1_l + source2_c); |
| 25346 | |
| 25347 | result = proc(source1_l, source2_c); |
| 25348 | if (expected_result != result) { |
| 25349 | printf("Failed long + signed char test, expected %ld, got %ld, for %ld + %d\n", |
| 25350 | expected_result, result, source1_l, source2_c); |
| 25351 | if (dumped == 0) cod_dump(gen_code); |
| 25352 | failed++; |
| 25353 | dumped++; |
| 25354 | } |
| 25355 | } |
| 25356 | } |
| 25357 | if (verbose) printf(" done\n"); |
| 25358 | cod_free_parse_context(context); |
| 25359 | cod_code_free(gen_code); |
| 25360 | } |
| 25361 | if ((only_run_test == NULL((void*)0)) || |
| 25362 | (strcmp(only_run_test, "l+uc") == 0)) { |
| 25363 | int i, j; |
| 25364 | static char code[] = "{\n\ |
| 25365 | long a = p1;\n\ |
| 25366 | unsigned char b = p2;\n\ |
| 25367 | return a + b;\n\ |
| 25368 | }"; |
| 25369 | |
| 25370 | long (*proc)(long a, unsigned char b); |
| 25371 | cod_parse_context context = new_cod_parse_context(); |
| 25372 | int dumped = 0; |
| 25373 | |
| 25374 | cod_code gen_code; |
| 25375 | |
| 25376 | /* test for long + unsigned char */ |
| 25377 | if (verbose) printf("test for long + unsigned char"); |
| 25378 | |
| 25379 | cod_assoc_externs(context, externs); |
| 25380 | cod_parse_for_context(extern_string, context); |
| 25381 | |
| 25382 | cod_subroutine_declaration("long proc(long p1, unsigned char p2)", |
| 25383 | context); |
| 25384 | gen_code = cod_code_gen(code, context); |
| 25385 | proc = (long (*)(long, unsigned char))(long)gen_code->func; |
| 25386 | |
| 25387 | |
| 25388 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 25389 | long source1_l = src1l_vals[i]; |
| 25390 | for (j=0 ; j < sizeof(src2uc_vals)/sizeof(src2uc_vals[0]) ; j++) { |
| 25391 | unsigned char source2_uc = src2uc_vals[j]; |
| 25392 | |
| 25393 | long expected_result; |
| 25394 | long result; |
| 25395 | |
| 25396 | |
| 25397 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 25398 | |
| 25399 | expected_result = (long) (source1_l + source2_uc); |
| 25400 | |
| 25401 | result = proc(source1_l, source2_uc); |
| 25402 | if (expected_result != result) { |
| 25403 | printf("Failed long + unsigned char test, expected %ld, got %ld, for %ld + %u\n", |
| 25404 | expected_result, result, source1_l, source2_uc); |
| 25405 | if (dumped == 0) cod_dump(gen_code); |
| 25406 | failed++; |
| 25407 | dumped++; |
| 25408 | } |
| 25409 | } |
| 25410 | } |
| 25411 | if (verbose) printf(" done\n"); |
| 25412 | cod_free_parse_context(context); |
| 25413 | cod_code_free(gen_code); |
| 25414 | } |
| 25415 | if ((only_run_test == NULL((void*)0)) || |
| 25416 | (strcmp(only_run_test, "l+s") == 0)) { |
| 25417 | int i, j; |
| 25418 | static char code[] = "{\n\ |
| 25419 | long a = p1;\n\ |
| 25420 | short b = p2;\n\ |
| 25421 | return a + b;\n\ |
| 25422 | }"; |
| 25423 | |
| 25424 | long (*proc)(long a, short b); |
| 25425 | cod_parse_context context = new_cod_parse_context(); |
| 25426 | int dumped = 0; |
| 25427 | |
| 25428 | cod_code gen_code; |
| 25429 | |
| 25430 | /* test for long + short */ |
| 25431 | if (verbose) printf("test for long + short"); |
| 25432 | |
| 25433 | cod_assoc_externs(context, externs); |
| 25434 | cod_parse_for_context(extern_string, context); |
| 25435 | |
| 25436 | cod_subroutine_declaration("long proc(long p1, short p2)", |
| 25437 | context); |
| 25438 | gen_code = cod_code_gen(code, context); |
| 25439 | proc = (long (*)(long, short))(long)gen_code->func; |
| 25440 | |
| 25441 | |
| 25442 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 25443 | long source1_l = src1l_vals[i]; |
| 25444 | for (j=0 ; j < sizeof(src2s_vals)/sizeof(src2s_vals[0]) ; j++) { |
| 25445 | short source2_s = src2s_vals[j]; |
| 25446 | |
| 25447 | long expected_result; |
| 25448 | long result; |
| 25449 | |
| 25450 | |
| 25451 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 25452 | |
| 25453 | expected_result = (long) (source1_l + source2_s); |
| 25454 | |
| 25455 | result = proc(source1_l, source2_s); |
| 25456 | if (expected_result != result) { |
| 25457 | printf("Failed long + short test, expected %ld, got %ld, for %ld + %d\n", |
| 25458 | expected_result, result, source1_l, source2_s); |
| 25459 | if (dumped == 0) cod_dump(gen_code); |
| 25460 | failed++; |
| 25461 | dumped++; |
| 25462 | } |
| 25463 | } |
| 25464 | } |
| 25465 | if (verbose) printf(" done\n"); |
| 25466 | cod_free_parse_context(context); |
| 25467 | cod_code_free(gen_code); |
| 25468 | } |
| 25469 | if ((only_run_test == NULL((void*)0)) || |
| 25470 | (strcmp(only_run_test, "l+us") == 0)) { |
| 25471 | int i, j; |
| 25472 | static char code[] = "{\n\ |
| 25473 | long a = p1;\n\ |
| 25474 | unsigned short b = p2;\n\ |
| 25475 | return a + b;\n\ |
| 25476 | }"; |
| 25477 | |
| 25478 | long (*proc)(long a, unsigned short b); |
| 25479 | cod_parse_context context = new_cod_parse_context(); |
| 25480 | int dumped = 0; |
| 25481 | |
| 25482 | cod_code gen_code; |
| 25483 | |
| 25484 | /* test for long + unsigned short */ |
| 25485 | if (verbose) printf("test for long + unsigned short"); |
| 25486 | |
| 25487 | cod_assoc_externs(context, externs); |
| 25488 | cod_parse_for_context(extern_string, context); |
| 25489 | |
| 25490 | cod_subroutine_declaration("long proc(long p1, unsigned short p2)", |
| 25491 | context); |
| 25492 | gen_code = cod_code_gen(code, context); |
| 25493 | proc = (long (*)(long, unsigned short))(long)gen_code->func; |
| 25494 | |
| 25495 | |
| 25496 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 25497 | long source1_l = src1l_vals[i]; |
| 25498 | for (j=0 ; j < sizeof(src2us_vals)/sizeof(src2us_vals[0]) ; j++) { |
| 25499 | unsigned short source2_us = src2us_vals[j]; |
| 25500 | |
| 25501 | long expected_result; |
| 25502 | long result; |
| 25503 | |
| 25504 | |
| 25505 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 25506 | |
| 25507 | expected_result = (long) (source1_l + source2_us); |
| 25508 | |
| 25509 | result = proc(source1_l, source2_us); |
| 25510 | if (expected_result != result) { |
| 25511 | printf("Failed long + unsigned short test, expected %ld, got %ld, for %ld + %u\n", |
| 25512 | expected_result, result, source1_l, source2_us); |
| 25513 | if (dumped == 0) cod_dump(gen_code); |
| 25514 | failed++; |
| 25515 | dumped++; |
| 25516 | } |
| 25517 | } |
| 25518 | } |
| 25519 | if (verbose) printf(" done\n"); |
| 25520 | cod_free_parse_context(context); |
| 25521 | cod_code_free(gen_code); |
| 25522 | } |
| 25523 | if ((only_run_test == NULL((void*)0)) || |
| 25524 | (strcmp(only_run_test, "l+i") == 0)) { |
| 25525 | int i, j; |
| 25526 | static char code[] = "{\n\ |
| 25527 | long a = p1;\n\ |
| 25528 | int b = p2;\n\ |
| 25529 | return a + b;\n\ |
| 25530 | }"; |
| 25531 | |
| 25532 | long (*proc)(long a, int b); |
| 25533 | cod_parse_context context = new_cod_parse_context(); |
| 25534 | int dumped = 0; |
| 25535 | |
| 25536 | cod_code gen_code; |
| 25537 | |
| 25538 | /* test for long + int */ |
| 25539 | if (verbose) printf("test for long + int"); |
| 25540 | |
| 25541 | cod_assoc_externs(context, externs); |
| 25542 | cod_parse_for_context(extern_string, context); |
| 25543 | |
| 25544 | cod_subroutine_declaration("long proc(long p1, int p2)", |
| 25545 | context); |
| 25546 | gen_code = cod_code_gen(code, context); |
| 25547 | proc = (long (*)(long, int))(long)gen_code->func; |
| 25548 | |
| 25549 | |
| 25550 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 25551 | long source1_l = src1l_vals[i]; |
| 25552 | for (j=0 ; j < sizeof(src2i_vals)/sizeof(src2i_vals[0]) ; j++) { |
| 25553 | int source2_i = src2i_vals[j]; |
| 25554 | |
| 25555 | long expected_result; |
| 25556 | long result; |
| 25557 | |
| 25558 | |
| 25559 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 25560 | |
| 25561 | expected_result = (long) (source1_l + source2_i); |
| 25562 | |
| 25563 | result = proc(source1_l, source2_i); |
| 25564 | if (expected_result != result) { |
| 25565 | printf("Failed long + int test, expected %ld, got %ld, for %ld + %d\n", |
| 25566 | expected_result, result, source1_l, source2_i); |
| 25567 | if (dumped == 0) cod_dump(gen_code); |
| 25568 | failed++; |
| 25569 | dumped++; |
| 25570 | } |
| 25571 | } |
| 25572 | } |
| 25573 | if (verbose) printf(" done\n"); |
| 25574 | cod_free_parse_context(context); |
| 25575 | cod_code_free(gen_code); |
| 25576 | } |
| 25577 | if ((only_run_test == NULL((void*)0)) || |
| 25578 | (strcmp(only_run_test, "l+u") == 0)) { |
| 25579 | int i, j; |
| 25580 | static char code[] = "{\n\ |
| 25581 | long a = p1;\n\ |
| 25582 | unsigned int b = p2;\n\ |
| 25583 | return a + b;\n\ |
| 25584 | }"; |
| 25585 | |
| 25586 | long (*proc)(long a, unsigned int b); |
| 25587 | cod_parse_context context = new_cod_parse_context(); |
| 25588 | int dumped = 0; |
| 25589 | |
| 25590 | cod_code gen_code; |
| 25591 | |
| 25592 | /* test for long + unsigned int */ |
| 25593 | if (verbose) printf("test for long + unsigned int"); |
| 25594 | |
| 25595 | cod_assoc_externs(context, externs); |
| 25596 | cod_parse_for_context(extern_string, context); |
| 25597 | |
| 25598 | cod_subroutine_declaration("long proc(long p1, unsigned int p2)", |
| 25599 | context); |
| 25600 | gen_code = cod_code_gen(code, context); |
| 25601 | proc = (long (*)(long, unsigned int))(long)gen_code->func; |
| 25602 | |
| 25603 | |
| 25604 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 25605 | long source1_l = src1l_vals[i]; |
| 25606 | for (j=0 ; j < sizeof(src2u_vals)/sizeof(src2u_vals[0]) ; j++) { |
| 25607 | unsigned int source2_u = src2u_vals[j]; |
| 25608 | |
| 25609 | long expected_result; |
| 25610 | long result; |
| 25611 | |
| 25612 | |
| 25613 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 25614 | |
| 25615 | expected_result = (long) (source1_l + source2_u); |
| 25616 | |
| 25617 | result = proc(source1_l, source2_u); |
| 25618 | if (expected_result != result) { |
| 25619 | printf("Failed long + unsigned int test, expected %ld, got %ld, for %ld + %u\n", |
| 25620 | expected_result, result, source1_l, source2_u); |
| 25621 | if (dumped == 0) cod_dump(gen_code); |
| 25622 | failed++; |
| 25623 | dumped++; |
| 25624 | } |
| 25625 | } |
| 25626 | } |
| 25627 | if (verbose) printf(" done\n"); |
| 25628 | cod_free_parse_context(context); |
| 25629 | cod_code_free(gen_code); |
| 25630 | } |
| 25631 | if ((only_run_test == NULL((void*)0)) || |
| 25632 | (strcmp(only_run_test, "l+ul") == 0)) { |
| 25633 | int i, j; |
| 25634 | static char code[] = "{\n\ |
| 25635 | long a = p1;\n\ |
| 25636 | unsigned long b = p2;\n\ |
| 25637 | return a + b;\n\ |
| 25638 | }"; |
| 25639 | |
| 25640 | long (*proc)(long a, unsigned long b); |
| 25641 | cod_parse_context context = new_cod_parse_context(); |
| 25642 | int dumped = 0; |
| 25643 | |
| 25644 | cod_code gen_code; |
| 25645 | |
| 25646 | /* test for long + unsigned long */ |
| 25647 | if (verbose) printf("test for long + unsigned long"); |
| 25648 | |
| 25649 | cod_assoc_externs(context, externs); |
| 25650 | cod_parse_for_context(extern_string, context); |
| 25651 | |
| 25652 | cod_subroutine_declaration("long proc(long p1, unsigned long p2)", |
| 25653 | context); |
| 25654 | gen_code = cod_code_gen(code, context); |
| 25655 | proc = (long (*)(long, unsigned long))(long)gen_code->func; |
| 25656 | |
| 25657 | |
| 25658 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 25659 | long source1_l = src1l_vals[i]; |
| 25660 | for (j=0 ; j < sizeof(src2ul_vals)/sizeof(src2ul_vals[0]) ; j++) { |
| 25661 | unsigned long source2_ul = src2ul_vals[j]; |
| 25662 | |
| 25663 | long expected_result; |
| 25664 | long result; |
| 25665 | |
| 25666 | |
| 25667 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 25668 | |
| 25669 | expected_result = (long) (source1_l + source2_ul); |
| 25670 | |
| 25671 | result = proc(source1_l, source2_ul); |
| 25672 | if (expected_result != result) { |
| 25673 | printf("Failed long + unsigned long test, expected %ld, got %ld, for %ld + %lu\n", |
| 25674 | expected_result, result, source1_l, source2_ul); |
| 25675 | if (dumped == 0) cod_dump(gen_code); |
| 25676 | failed++; |
| 25677 | dumped++; |
| 25678 | } |
| 25679 | } |
| 25680 | } |
| 25681 | if (verbose) printf(" done\n"); |
| 25682 | cod_free_parse_context(context); |
| 25683 | cod_code_free(gen_code); |
| 25684 | } |
| 25685 | if ((only_run_test == NULL((void*)0)) || |
| 25686 | (strcmp(only_run_test, "l+l") == 0)) { |
| 25687 | int i, j; |
| 25688 | static char code[] = "{\n\ |
| 25689 | long a = p1;\n\ |
| 25690 | long b = p2;\n\ |
| 25691 | return a + b;\n\ |
| 25692 | }"; |
| 25693 | |
| 25694 | long (*proc)(long a, long b); |
| 25695 | cod_parse_context context = new_cod_parse_context(); |
| 25696 | int dumped = 0; |
| 25697 | |
| 25698 | cod_code gen_code; |
| 25699 | |
| 25700 | /* test for long + long */ |
| 25701 | if (verbose) printf("test for long + long"); |
| 25702 | |
| 25703 | cod_assoc_externs(context, externs); |
| 25704 | cod_parse_for_context(extern_string, context); |
| 25705 | |
| 25706 | cod_subroutine_declaration("long proc(long p1, long p2)", |
| 25707 | context); |
| 25708 | gen_code = cod_code_gen(code, context); |
| 25709 | proc = (long (*)(long, long))(long)gen_code->func; |
| 25710 | |
| 25711 | |
| 25712 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 25713 | long source1_l = src1l_vals[i]; |
| 25714 | for (j=0 ; j < sizeof(src2l_vals)/sizeof(src2l_vals[0]) ; j++) { |
| 25715 | long source2_l = src2l_vals[j]; |
| 25716 | |
| 25717 | long expected_result; |
| 25718 | long result; |
| 25719 | |
| 25720 | |
| 25721 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 25722 | |
| 25723 | expected_result = (long) (source1_l + source2_l); |
| 25724 | |
| 25725 | result = proc(source1_l, source2_l); |
| 25726 | if (expected_result != result) { |
| 25727 | printf("Failed long + long test, expected %ld, got %ld, for %ld + %ld\n", |
| 25728 | expected_result, result, source1_l, source2_l); |
| 25729 | if (dumped == 0) cod_dump(gen_code); |
| 25730 | failed++; |
| 25731 | dumped++; |
| 25732 | } |
| 25733 | } |
| 25734 | } |
| 25735 | if (verbose) printf(" done\n"); |
| 25736 | cod_free_parse_context(context); |
| 25737 | cod_code_free(gen_code); |
| 25738 | } |
| 25739 | if ((only_run_test == NULL((void*)0)) || |
| 25740 | (strcmp(only_run_test, "l+f") == 0)) { |
| 25741 | int i, j; |
| 25742 | static char code[] = "{\n\ |
| 25743 | long a = p1;\n\ |
| 25744 | float b = p2;\n\ |
| 25745 | return a + b;\n\ |
| 25746 | }"; |
| 25747 | |
| 25748 | long (*proc)(long a, float b); |
| 25749 | cod_parse_context context = new_cod_parse_context(); |
| 25750 | int dumped = 0; |
| 25751 | |
| 25752 | cod_code gen_code; |
| 25753 | |
| 25754 | /* test for long + float */ |
| 25755 | if (verbose) printf("test for long + float"); |
| 25756 | |
| 25757 | cod_assoc_externs(context, externs); |
| 25758 | cod_parse_for_context(extern_string, context); |
| 25759 | |
| 25760 | cod_subroutine_declaration("long proc(long p1, float p2)", |
| 25761 | context); |
| 25762 | gen_code = cod_code_gen(code, context); |
| 25763 | proc = (long (*)(long, float))(long)gen_code->func; |
| 25764 | |
| 25765 | |
| 25766 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 25767 | long source1_l = src1l_vals[i]; |
| 25768 | for (j=0 ; j < sizeof(src2f_vals)/sizeof(src2f_vals[0]) ; j++) { |
| 25769 | float source2_f = src2f_vals[j]; |
| 25770 | double range = 0.000001 * (fabs((double)source1_l) + fabs((double)source2_f)); |
| 25771 | long expected_result; |
| 25772 | long result; |
| 25773 | |
| 25774 | |
| 25775 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 25776 | |
| 25777 | expected_result = (long) (source1_l + source2_f); |
| 25778 | |
| 25779 | result = proc(source1_l, source2_f); |
| 25780 | range += 1.0; |
| 25781 | if ((result > (expected_result + range)) || (result < (expected_result - range))) { |
| 25782 | printf("Failed long + float test, expected %ld, got %ld, for %ld + %g\n", |
| 25783 | expected_result, result, source1_l, source2_f); |
| 25784 | if (dumped == 0) cod_dump(gen_code); |
| 25785 | failed++; |
| 25786 | dumped++; |
| 25787 | } |
| 25788 | } |
| 25789 | } |
| 25790 | if (verbose) printf(" done\n"); |
| 25791 | cod_free_parse_context(context); |
| 25792 | cod_code_free(gen_code); |
| 25793 | } |
| 25794 | if ((only_run_test == NULL((void*)0)) || |
| 25795 | (strcmp(only_run_test, "l+d") == 0)) { |
| 25796 | int i, j; |
| 25797 | static char code[] = "{\n\ |
| 25798 | long a = p1;\n\ |
| 25799 | double b = p2;\n\ |
| 25800 | return a + b;\n\ |
| 25801 | }"; |
| 25802 | |
| 25803 | long (*proc)(long a, double b); |
| 25804 | cod_parse_context context = new_cod_parse_context(); |
| 25805 | int dumped = 0; |
| 25806 | |
| 25807 | cod_code gen_code; |
| 25808 | |
| 25809 | /* test for long + double */ |
| 25810 | if (verbose) printf("test for long + double"); |
| 25811 | |
| 25812 | cod_assoc_externs(context, externs); |
| 25813 | cod_parse_for_context(extern_string, context); |
| 25814 | |
| 25815 | cod_subroutine_declaration("long proc(long p1, double p2)", |
| 25816 | context); |
| 25817 | gen_code = cod_code_gen(code, context); |
| 25818 | proc = (long (*)(long, double))(long)gen_code->func; |
| 25819 | |
| 25820 | |
| 25821 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 25822 | long source1_l = src1l_vals[i]; |
| 25823 | for (j=0 ; j < sizeof(src2d_vals)/sizeof(src2d_vals[0]) ; j++) { |
| 25824 | double source2_d = src2d_vals[j]; |
| 25825 | |
| 25826 | long expected_result; |
| 25827 | long result; |
| 25828 | |
| 25829 | |
| 25830 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 25831 | |
| 25832 | expected_result = (long) (source1_l + source2_d); |
| 25833 | |
| 25834 | result = proc(source1_l, source2_d); |
| 25835 | if (expected_result != result) { |
| 25836 | printf("Failed long + double test, expected %ld, got %ld, for %ld + %g\n", |
| 25837 | expected_result, result, source1_l, source2_d); |
| 25838 | if (dumped == 0) cod_dump(gen_code); |
| 25839 | failed++; |
| 25840 | dumped++; |
| 25841 | } |
| 25842 | } |
| 25843 | } |
| 25844 | if (verbose) printf(" done\n"); |
| 25845 | cod_free_parse_context(context); |
| 25846 | cod_code_free(gen_code); |
| 25847 | } |
| 25848 | } |
| 25849 | void add_f_tests() |
| 25850 | { |
| 25851 | if ((only_run_test == NULL((void*)0)) || |
| 25852 | (strcmp(only_run_test, "f+c") == 0)) { |
| 25853 | int i, j; |
| 25854 | static char code[] = "{\n\ |
| 25855 | float a = p1;\n\ |
| 25856 | signed char b = p2;\n\ |
| 25857 | return a + b;\n\ |
| 25858 | }"; |
| 25859 | |
| 25860 | float (*proc)(float a, signed char b); |
| 25861 | cod_parse_context context = new_cod_parse_context(); |
| 25862 | int dumped = 0; |
| 25863 | |
| 25864 | cod_code gen_code; |
| 25865 | |
| 25866 | /* test for float + signed char */ |
| 25867 | if (verbose) printf("test for float + signed char"); |
| 25868 | |
| 25869 | cod_assoc_externs(context, externs); |
| 25870 | cod_parse_for_context(extern_string, context); |
| 25871 | |
| 25872 | cod_subroutine_declaration("float proc(float p1, signed char p2)", |
| 25873 | context); |
| 25874 | gen_code = cod_code_gen(code, context); |
| 25875 | proc = (float (*)(float, signed char))(long)gen_code->func; |
| 25876 | |
| 25877 | |
| 25878 | for (i=0 ; i < sizeof(src1f_vals)/sizeof(src1f_vals[0]) ; i++) { |
| 25879 | float source1_f = src1f_vals[i]; |
| 25880 | for (j=0 ; j < sizeof(src2c_vals)/sizeof(src2c_vals[0]) ; j++) { |
| 25881 | signed char source2_c = src2c_vals[j]; |
| 25882 | double range = 0.000001 * (fabs((double)source1_f) + fabs((double)source2_c)); |
| 25883 | float expected_result; |
| 25884 | float result; |
| 25885 | |
| 25886 | |
| 25887 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 25888 | |
| 25889 | expected_result = (float) (source1_f + source2_c); |
| 25890 | |
| 25891 | result = proc(source1_f, source2_c); |
| 25892 | range += 1.0; |
| 25893 | if ((result > (expected_result + range)) || (result < (expected_result - range))) { |
| 25894 | printf("Failed float + signed char test, expected %g, got %g, for %g + %d\n", |
| 25895 | expected_result, result, source1_f, source2_c); |
| 25896 | if (dumped == 0) cod_dump(gen_code); |
| 25897 | failed++; |
| 25898 | dumped++; |
| 25899 | } |
| 25900 | } |
| 25901 | } |
| 25902 | if (verbose) printf(" done\n"); |
| 25903 | cod_free_parse_context(context); |
| 25904 | cod_code_free(gen_code); |
| 25905 | } |
| 25906 | if ((only_run_test == NULL((void*)0)) || |
| 25907 | (strcmp(only_run_test, "f+uc") == 0)) { |
| 25908 | int i, j; |
| 25909 | static char code[] = "{\n\ |
| 25910 | float a = p1;\n\ |
| 25911 | unsigned char b = p2;\n\ |
| 25912 | return a + b;\n\ |
| 25913 | }"; |
| 25914 | |
| 25915 | float (*proc)(float a, unsigned char b); |
| 25916 | cod_parse_context context = new_cod_parse_context(); |
| 25917 | int dumped = 0; |
| 25918 | |
| 25919 | cod_code gen_code; |
| 25920 | |
| 25921 | /* test for float + unsigned char */ |
| 25922 | if (verbose) printf("test for float + unsigned char"); |
| 25923 | |
| 25924 | cod_assoc_externs(context, externs); |
| 25925 | cod_parse_for_context(extern_string, context); |
| 25926 | |
| 25927 | cod_subroutine_declaration("float proc(float p1, unsigned char p2)", |
| 25928 | context); |
| 25929 | gen_code = cod_code_gen(code, context); |
| 25930 | proc = (float (*)(float, unsigned char))(long)gen_code->func; |
| 25931 | |
| 25932 | |
| 25933 | for (i=0 ; i < sizeof(src1f_vals)/sizeof(src1f_vals[0]) ; i++) { |
| 25934 | float source1_f = src1f_vals[i]; |
| 25935 | for (j=0 ; j < sizeof(src2uc_vals)/sizeof(src2uc_vals[0]) ; j++) { |
| 25936 | unsigned char source2_uc = src2uc_vals[j]; |
| 25937 | double range = 0.000001 * (fabs((double)source1_f) + fabs((double)source2_uc)); |
| 25938 | float expected_result; |
| 25939 | float result; |
| 25940 | |
| 25941 | |
| 25942 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 25943 | |
| 25944 | expected_result = (float) (source1_f + source2_uc); |
| 25945 | |
| 25946 | result = proc(source1_f, source2_uc); |
| 25947 | range += 1.0; |
| 25948 | if ((result > (expected_result + range)) || (result < (expected_result - range))) { |
| 25949 | printf("Failed float + unsigned char test, expected %g, got %g, for %g + %u\n", |
| 25950 | expected_result, result, source1_f, source2_uc); |
| 25951 | if (dumped == 0) cod_dump(gen_code); |
| 25952 | failed++; |
| 25953 | dumped++; |
| 25954 | } |
| 25955 | } |
| 25956 | } |
| 25957 | if (verbose) printf(" done\n"); |
| 25958 | cod_free_parse_context(context); |
| 25959 | cod_code_free(gen_code); |
| 25960 | } |
| 25961 | if ((only_run_test == NULL((void*)0)) || |
| 25962 | (strcmp(only_run_test, "f+s") == 0)) { |
| 25963 | int i, j; |
| 25964 | static char code[] = "{\n\ |
| 25965 | float a = p1;\n\ |
| 25966 | short b = p2;\n\ |
| 25967 | return a + b;\n\ |
| 25968 | }"; |
| 25969 | |
| 25970 | float (*proc)(float a, short b); |
| 25971 | cod_parse_context context = new_cod_parse_context(); |
| 25972 | int dumped = 0; |
| 25973 | |
| 25974 | cod_code gen_code; |
| 25975 | |
| 25976 | /* test for float + short */ |
| 25977 | if (verbose) printf("test for float + short"); |
| 25978 | |
| 25979 | cod_assoc_externs(context, externs); |
| 25980 | cod_parse_for_context(extern_string, context); |
| 25981 | |
| 25982 | cod_subroutine_declaration("float proc(float p1, short p2)", |
| 25983 | context); |
| 25984 | gen_code = cod_code_gen(code, context); |
| 25985 | proc = (float (*)(float, short))(long)gen_code->func; |
| 25986 | |
| 25987 | |
| 25988 | for (i=0 ; i < sizeof(src1f_vals)/sizeof(src1f_vals[0]) ; i++) { |
| 25989 | float source1_f = src1f_vals[i]; |
| 25990 | for (j=0 ; j < sizeof(src2s_vals)/sizeof(src2s_vals[0]) ; j++) { |
| 25991 | short source2_s = src2s_vals[j]; |
| 25992 | double range = 0.000001 * (fabs((double)source1_f) + fabs((double)source2_s)); |
| 25993 | float expected_result; |
| 25994 | float result; |
| 25995 | |
| 25996 | |
| 25997 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 25998 | |
| 25999 | expected_result = (float) (source1_f + source2_s); |
| 26000 | |
| 26001 | result = proc(source1_f, source2_s); |
| 26002 | range += 1.0; |
| 26003 | if ((result > (expected_result + range)) || (result < (expected_result - range))) { |
| 26004 | printf("Failed float + short test, expected %g, got %g, for %g + %d\n", |
| 26005 | expected_result, result, source1_f, source2_s); |
| 26006 | if (dumped == 0) cod_dump(gen_code); |
| 26007 | failed++; |
| 26008 | dumped++; |
| 26009 | } |
| 26010 | } |
| 26011 | } |
| 26012 | if (verbose) printf(" done\n"); |
| 26013 | cod_free_parse_context(context); |
| 26014 | cod_code_free(gen_code); |
| 26015 | } |
| 26016 | if ((only_run_test == NULL((void*)0)) || |
| 26017 | (strcmp(only_run_test, "f+us") == 0)) { |
| 26018 | int i, j; |
| 26019 | static char code[] = "{\n\ |
| 26020 | float a = p1;\n\ |
| 26021 | unsigned short b = p2;\n\ |
| 26022 | return a + b;\n\ |
| 26023 | }"; |
| 26024 | |
| 26025 | float (*proc)(float a, unsigned short b); |
| 26026 | cod_parse_context context = new_cod_parse_context(); |
| 26027 | int dumped = 0; |
| 26028 | |
| 26029 | cod_code gen_code; |
| 26030 | |
| 26031 | /* test for float + unsigned short */ |
| 26032 | if (verbose) printf("test for float + unsigned short"); |
| 26033 | |
| 26034 | cod_assoc_externs(context, externs); |
| 26035 | cod_parse_for_context(extern_string, context); |
| 26036 | |
| 26037 | cod_subroutine_declaration("float proc(float p1, unsigned short p2)", |
| 26038 | context); |
| 26039 | gen_code = cod_code_gen(code, context); |
| 26040 | proc = (float (*)(float, unsigned short))(long)gen_code->func; |
| 26041 | |
| 26042 | |
| 26043 | for (i=0 ; i < sizeof(src1f_vals)/sizeof(src1f_vals[0]) ; i++) { |
| 26044 | float source1_f = src1f_vals[i]; |
| 26045 | for (j=0 ; j < sizeof(src2us_vals)/sizeof(src2us_vals[0]) ; j++) { |
| 26046 | unsigned short source2_us = src2us_vals[j]; |
| 26047 | double range = 0.000001 * (fabs((double)source1_f) + fabs((double)source2_us)); |
| 26048 | float expected_result; |
| 26049 | float result; |
| 26050 | |
| 26051 | |
| 26052 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 26053 | |
| 26054 | expected_result = (float) (source1_f + source2_us); |
| 26055 | |
| 26056 | result = proc(source1_f, source2_us); |
| 26057 | range += 1.0; |
| 26058 | if ((result > (expected_result + range)) || (result < (expected_result - range))) { |
| 26059 | printf("Failed float + unsigned short test, expected %g, got %g, for %g + %u\n", |
| 26060 | expected_result, result, source1_f, source2_us); |
| 26061 | if (dumped == 0) cod_dump(gen_code); |
| 26062 | failed++; |
| 26063 | dumped++; |
| 26064 | } |
| 26065 | } |
| 26066 | } |
| 26067 | if (verbose) printf(" done\n"); |
| 26068 | cod_free_parse_context(context); |
| 26069 | cod_code_free(gen_code); |
| 26070 | } |
| 26071 | if ((only_run_test == NULL((void*)0)) || |
| 26072 | (strcmp(only_run_test, "f+i") == 0)) { |
| 26073 | int i, j; |
| 26074 | static char code[] = "{\n\ |
| 26075 | float a = p1;\n\ |
| 26076 | int b = p2;\n\ |
| 26077 | return a + b;\n\ |
| 26078 | }"; |
| 26079 | |
| 26080 | float (*proc)(float a, int b); |
| 26081 | cod_parse_context context = new_cod_parse_context(); |
| 26082 | int dumped = 0; |
| 26083 | |
| 26084 | cod_code gen_code; |
| 26085 | |
| 26086 | /* test for float + int */ |
| 26087 | if (verbose) printf("test for float + int"); |
| 26088 | |
| 26089 | cod_assoc_externs(context, externs); |
| 26090 | cod_parse_for_context(extern_string, context); |
| 26091 | |
| 26092 | cod_subroutine_declaration("float proc(float p1, int p2)", |
| 26093 | context); |
| 26094 | gen_code = cod_code_gen(code, context); |
| 26095 | proc = (float (*)(float, int))(long)gen_code->func; |
| 26096 | |
| 26097 | |
| 26098 | for (i=0 ; i < sizeof(src1f_vals)/sizeof(src1f_vals[0]) ; i++) { |
| 26099 | float source1_f = src1f_vals[i]; |
| 26100 | for (j=0 ; j < sizeof(src2i_vals)/sizeof(src2i_vals[0]) ; j++) { |
| 26101 | int source2_i = src2i_vals[j]; |
| 26102 | double range = 0.000001 * (fabs((double)source1_f) + fabs((double)source2_i)); |
| 26103 | float expected_result; |
| 26104 | float result; |
| 26105 | |
| 26106 | |
| 26107 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 26108 | |
| 26109 | expected_result = (float) (source1_f + source2_i); |
| 26110 | |
| 26111 | result = proc(source1_f, source2_i); |
| 26112 | range += 1.0; |
| 26113 | if ((result > (expected_result + range)) || (result < (expected_result - range))) { |
| 26114 | printf("Failed float + int test, expected %g, got %g, for %g + %d\n", |
| 26115 | expected_result, result, source1_f, source2_i); |
| 26116 | if (dumped == 0) cod_dump(gen_code); |
| 26117 | failed++; |
| 26118 | dumped++; |
| 26119 | } |
| 26120 | } |
| 26121 | } |
| 26122 | if (verbose) printf(" done\n"); |
| 26123 | cod_free_parse_context(context); |
| 26124 | cod_code_free(gen_code); |
| 26125 | } |
| 26126 | if ((only_run_test == NULL((void*)0)) || |
| 26127 | (strcmp(only_run_test, "f+u") == 0)) { |
| 26128 | int i, j; |
| 26129 | static char code[] = "{\n\ |
| 26130 | float a = p1;\n\ |
| 26131 | unsigned int b = p2;\n\ |
| 26132 | return a + b;\n\ |
| 26133 | }"; |
| 26134 | |
| 26135 | float (*proc)(float a, unsigned int b); |
| 26136 | cod_parse_context context = new_cod_parse_context(); |
| 26137 | int dumped = 0; |
| 26138 | |
| 26139 | cod_code gen_code; |
| 26140 | |
| 26141 | /* test for float + unsigned int */ |
| 26142 | if (verbose) printf("test for float + unsigned int"); |
| 26143 | |
| 26144 | cod_assoc_externs(context, externs); |
| 26145 | cod_parse_for_context(extern_string, context); |
| 26146 | |
| 26147 | cod_subroutine_declaration("float proc(float p1, unsigned int p2)", |
| 26148 | context); |
| 26149 | gen_code = cod_code_gen(code, context); |
| 26150 | proc = (float (*)(float, unsigned int))(long)gen_code->func; |
| 26151 | |
| 26152 | |
| 26153 | for (i=0 ; i < sizeof(src1f_vals)/sizeof(src1f_vals[0]) ; i++) { |
| 26154 | float source1_f = src1f_vals[i]; |
| 26155 | for (j=0 ; j < sizeof(src2u_vals)/sizeof(src2u_vals[0]) ; j++) { |
| 26156 | unsigned int source2_u = src2u_vals[j]; |
| 26157 | double range = 0.000001 * (fabs((double)source1_f) + fabs((double)source2_u)); |
| 26158 | float expected_result; |
| 26159 | float result; |
| 26160 | |
| 26161 | |
| 26162 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 26163 | |
| 26164 | expected_result = (float) (source1_f + source2_u); |
| 26165 | |
| 26166 | result = proc(source1_f, source2_u); |
| 26167 | range += 1.0; |
| 26168 | if ((result > (expected_result + range)) || (result < (expected_result - range))) { |
| 26169 | printf("Failed float + unsigned int test, expected %g, got %g, for %g + %u\n", |
| 26170 | expected_result, result, source1_f, source2_u); |
| 26171 | if (dumped == 0) cod_dump(gen_code); |
| 26172 | failed++; |
| 26173 | dumped++; |
| 26174 | } |
| 26175 | } |
| 26176 | } |
| 26177 | if (verbose) printf(" done\n"); |
| 26178 | cod_free_parse_context(context); |
| 26179 | cod_code_free(gen_code); |
| 26180 | } |
| 26181 | if ((only_run_test == NULL((void*)0)) || |
| 26182 | (strcmp(only_run_test, "f+ul") == 0)) { |
| 26183 | int i, j; |
| 26184 | static char code[] = "{\n\ |
| 26185 | float a = p1;\n\ |
| 26186 | unsigned long b = p2;\n\ |
| 26187 | return a + b;\n\ |
| 26188 | }"; |
| 26189 | |
| 26190 | float (*proc)(float a, unsigned long b); |
| 26191 | cod_parse_context context = new_cod_parse_context(); |
| 26192 | int dumped = 0; |
| 26193 | |
| 26194 | cod_code gen_code; |
| 26195 | |
| 26196 | /* test for float + unsigned long */ |
| 26197 | if (verbose) printf("test for float + unsigned long"); |
| 26198 | |
| 26199 | cod_assoc_externs(context, externs); |
| 26200 | cod_parse_for_context(extern_string, context); |
| 26201 | |
| 26202 | cod_subroutine_declaration("float proc(float p1, unsigned long p2)", |
| 26203 | context); |
| 26204 | gen_code = cod_code_gen(code, context); |
| 26205 | proc = (float (*)(float, unsigned long))(long)gen_code->func; |
| 26206 | |
| 26207 | |
| 26208 | for (i=0 ; i < sizeof(src1f_vals)/sizeof(src1f_vals[0]) ; i++) { |
| 26209 | float source1_f = src1f_vals[i]; |
| 26210 | for (j=0 ; j < sizeof(src2ul_vals)/sizeof(src2ul_vals[0]) ; j++) { |
| 26211 | unsigned long source2_ul = src2ul_vals[j]; |
| 26212 | double range = 0.000001 * (fabs((double)source1_f) + fabs((double)source2_ul)); |
| 26213 | float expected_result; |
| 26214 | float result; |
| 26215 | |
| 26216 | |
| 26217 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 26218 | |
| 26219 | expected_result = (float) (source1_f + source2_ul); |
| 26220 | |
| 26221 | result = proc(source1_f, source2_ul); |
| 26222 | range += 1.0; |
| 26223 | if ((result > (expected_result + range)) || (result < (expected_result - range))) { |
| 26224 | printf("Failed float + unsigned long test, expected %g, got %g, for %g + %lu\n", |
| 26225 | expected_result, result, source1_f, source2_ul); |
| 26226 | if (dumped == 0) cod_dump(gen_code); |
| 26227 | failed++; |
| 26228 | dumped++; |
| 26229 | } |
| 26230 | } |
| 26231 | } |
| 26232 | if (verbose) printf(" done\n"); |
| 26233 | cod_free_parse_context(context); |
| 26234 | cod_code_free(gen_code); |
| 26235 | } |
| 26236 | if ((only_run_test == NULL((void*)0)) || |
| 26237 | (strcmp(only_run_test, "f+l") == 0)) { |
| 26238 | int i, j; |
| 26239 | static char code[] = "{\n\ |
| 26240 | float a = p1;\n\ |
| 26241 | long b = p2;\n\ |
| 26242 | return a + b;\n\ |
| 26243 | }"; |
| 26244 | |
| 26245 | float (*proc)(float a, long b); |
| 26246 | cod_parse_context context = new_cod_parse_context(); |
| 26247 | int dumped = 0; |
| 26248 | |
| 26249 | cod_code gen_code; |
| 26250 | |
| 26251 | /* test for float + long */ |
| 26252 | if (verbose) printf("test for float + long"); |
| 26253 | |
| 26254 | cod_assoc_externs(context, externs); |
| 26255 | cod_parse_for_context(extern_string, context); |
| 26256 | |
| 26257 | cod_subroutine_declaration("float proc(float p1, long p2)", |
| 26258 | context); |
| 26259 | gen_code = cod_code_gen(code, context); |
| 26260 | proc = (float (*)(float, long))(long)gen_code->func; |
| 26261 | |
| 26262 | |
| 26263 | for (i=0 ; i < sizeof(src1f_vals)/sizeof(src1f_vals[0]) ; i++) { |
| 26264 | float source1_f = src1f_vals[i]; |
| 26265 | for (j=0 ; j < sizeof(src2l_vals)/sizeof(src2l_vals[0]) ; j++) { |
| 26266 | long source2_l = src2l_vals[j]; |
| 26267 | double range = 0.000001 * (fabs((double)source1_f) + fabs((double)source2_l)); |
| 26268 | float expected_result; |
| 26269 | float result; |
| 26270 | |
| 26271 | |
| 26272 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 26273 | |
| 26274 | expected_result = (float) (source1_f + source2_l); |
| 26275 | |
| 26276 | result = proc(source1_f, source2_l); |
| 26277 | range += 1.0; |
| 26278 | if ((result > (expected_result + range)) || (result < (expected_result - range))) { |
| 26279 | printf("Failed float + long test, expected %g, got %g, for %g + %ld\n", |
| 26280 | expected_result, result, source1_f, source2_l); |
| 26281 | if (dumped == 0) cod_dump(gen_code); |
| 26282 | failed++; |
| 26283 | dumped++; |
| 26284 | } |
| 26285 | } |
| 26286 | } |
| 26287 | if (verbose) printf(" done\n"); |
| 26288 | cod_free_parse_context(context); |
| 26289 | cod_code_free(gen_code); |
| 26290 | } |
| 26291 | if ((only_run_test == NULL((void*)0)) || |
| 26292 | (strcmp(only_run_test, "f+f") == 0)) { |
| 26293 | int i, j; |
| 26294 | static char code[] = "{\n\ |
| 26295 | float a = p1;\n\ |
| 26296 | float b = p2;\n\ |
| 26297 | return a + b;\n\ |
| 26298 | }"; |
| 26299 | |
| 26300 | float (*proc)(float a, float b); |
| 26301 | cod_parse_context context = new_cod_parse_context(); |
| 26302 | int dumped = 0; |
| 26303 | |
| 26304 | cod_code gen_code; |
| 26305 | |
| 26306 | /* test for float + float */ |
| 26307 | if (verbose) printf("test for float + float"); |
| 26308 | |
| 26309 | cod_assoc_externs(context, externs); |
| 26310 | cod_parse_for_context(extern_string, context); |
| 26311 | |
| 26312 | cod_subroutine_declaration("float proc(float p1, float p2)", |
| 26313 | context); |
| 26314 | gen_code = cod_code_gen(code, context); |
| 26315 | proc = (float (*)(float, float))(long)gen_code->func; |
| 26316 | |
| 26317 | |
| 26318 | for (i=0 ; i < sizeof(src1f_vals)/sizeof(src1f_vals[0]) ; i++) { |
| 26319 | float source1_f = src1f_vals[i]; |
| 26320 | for (j=0 ; j < sizeof(src2f_vals)/sizeof(src2f_vals[0]) ; j++) { |
| 26321 | float source2_f = src2f_vals[j]; |
| 26322 | double range = 0.000001 * (fabs((double)source1_f) + fabs((double)source2_f)); |
| 26323 | float expected_result; |
| 26324 | float result; |
| 26325 | |
| 26326 | |
| 26327 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 26328 | |
| 26329 | expected_result = (float) (source1_f + source2_f); |
| 26330 | |
| 26331 | result = proc(source1_f, source2_f); |
| 26332 | if ((result > (expected_result + range)) || (result < (expected_result - range))) { |
| 26333 | printf("Failed float + float test, expected %g, got %g, for %g + %g\n", |
| 26334 | expected_result, result, source1_f, source2_f); |
| 26335 | if (dumped == 0) cod_dump(gen_code); |
| 26336 | failed++; |
| 26337 | dumped++; |
| 26338 | } |
| 26339 | } |
| 26340 | } |
| 26341 | if (verbose) printf(" done\n"); |
| 26342 | cod_free_parse_context(context); |
| 26343 | cod_code_free(gen_code); |
| 26344 | } |
| 26345 | if ((only_run_test == NULL((void*)0)) || |
| 26346 | (strcmp(only_run_test, "f+d") == 0)) { |
| 26347 | int i, j; |
| 26348 | static char code[] = "{\n\ |
| 26349 | float a = p1;\n\ |
| 26350 | double b = p2;\n\ |
| 26351 | return a + b;\n\ |
| 26352 | }"; |
| 26353 | |
| 26354 | float (*proc)(float a, double b); |
| 26355 | cod_parse_context context = new_cod_parse_context(); |
| 26356 | int dumped = 0; |
| 26357 | |
| 26358 | cod_code gen_code; |
| 26359 | |
| 26360 | /* test for float + double */ |
| 26361 | if (verbose) printf("test for float + double"); |
| 26362 | |
| 26363 | cod_assoc_externs(context, externs); |
| 26364 | cod_parse_for_context(extern_string, context); |
| 26365 | |
| 26366 | cod_subroutine_declaration("float proc(float p1, double p2)", |
| 26367 | context); |
| 26368 | gen_code = cod_code_gen(code, context); |
| 26369 | proc = (float (*)(float, double))(long)gen_code->func; |
| 26370 | |
| 26371 | |
| 26372 | for (i=0 ; i < sizeof(src1f_vals)/sizeof(src1f_vals[0]) ; i++) { |
| 26373 | float source1_f = src1f_vals[i]; |
| 26374 | for (j=0 ; j < sizeof(src2d_vals)/sizeof(src2d_vals[0]) ; j++) { |
| 26375 | double source2_d = src2d_vals[j]; |
| 26376 | double range = 0.000001 * (fabs((double)source1_f) + fabs((double)source2_d)); |
| 26377 | float expected_result; |
| 26378 | float result; |
| 26379 | |
| 26380 | |
| 26381 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 26382 | |
| 26383 | expected_result = (float) (source1_f + source2_d); |
| 26384 | |
| 26385 | result = proc(source1_f, source2_d); |
| 26386 | range += 1.0; |
| 26387 | if ((result > (expected_result + range)) || (result < (expected_result - range))) { |
| 26388 | printf("Failed float + double test, expected %g, got %g, for %g + %g\n", |
| 26389 | expected_result, result, source1_f, source2_d); |
| 26390 | if (dumped == 0) cod_dump(gen_code); |
| 26391 | failed++; |
| 26392 | dumped++; |
| 26393 | } |
| 26394 | } |
| 26395 | } |
| 26396 | if (verbose) printf(" done\n"); |
| 26397 | cod_free_parse_context(context); |
| 26398 | cod_code_free(gen_code); |
| 26399 | } |
| 26400 | } |
| 26401 | void add_d_tests() |
| 26402 | { |
| 26403 | if ((only_run_test == NULL((void*)0)) || |
| 26404 | (strcmp(only_run_test, "d+c") == 0)) { |
| 26405 | int i, j; |
| 26406 | static char code[] = "{\n\ |
| 26407 | double a = p1;\n\ |
| 26408 | signed char b = p2;\n\ |
| 26409 | return a + b;\n\ |
| 26410 | }"; |
| 26411 | |
| 26412 | double (*proc)(double a, signed char b); |
| 26413 | cod_parse_context context = new_cod_parse_context(); |
| 26414 | int dumped = 0; |
| 26415 | |
| 26416 | cod_code gen_code; |
| 26417 | |
| 26418 | /* test for double + signed char */ |
| 26419 | if (verbose) printf("test for double + signed char"); |
| 26420 | |
| 26421 | cod_assoc_externs(context, externs); |
| 26422 | cod_parse_for_context(extern_string, context); |
| 26423 | |
| 26424 | cod_subroutine_declaration("double proc(double p1, signed char p2)", |
| 26425 | context); |
| 26426 | gen_code = cod_code_gen(code, context); |
| 26427 | proc = (double (*)(double, signed char))(long)gen_code->func; |
| 26428 | |
| 26429 | |
| 26430 | for (i=0 ; i < sizeof(src1d_vals)/sizeof(src1d_vals[0]) ; i++) { |
| 26431 | double source1_d = src1d_vals[i]; |
| 26432 | for (j=0 ; j < sizeof(src2c_vals)/sizeof(src2c_vals[0]) ; j++) { |
| 26433 | signed char source2_c = src2c_vals[j]; |
| 26434 | |
| 26435 | double expected_result; |
| 26436 | double result; |
| 26437 | |
| 26438 | |
| 26439 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 26440 | |
| 26441 | expected_result = (double) (source1_d + source2_c); |
| 26442 | |
| 26443 | result = proc(source1_d, source2_c); |
| 26444 | if (expected_result != result) { |
| 26445 | printf("Failed double + signed char test, expected %g, got %g, for %g + %d\n", |
| 26446 | expected_result, result, source1_d, source2_c); |
| 26447 | if (dumped == 0) cod_dump(gen_code); |
| 26448 | failed++; |
| 26449 | dumped++; |
| 26450 | } |
| 26451 | } |
| 26452 | } |
| 26453 | if (verbose) printf(" done\n"); |
| 26454 | cod_free_parse_context(context); |
| 26455 | cod_code_free(gen_code); |
| 26456 | } |
| 26457 | if ((only_run_test == NULL((void*)0)) || |
| 26458 | (strcmp(only_run_test, "d+uc") == 0)) { |
| 26459 | int i, j; |
| 26460 | static char code[] = "{\n\ |
| 26461 | double a = p1;\n\ |
| 26462 | unsigned char b = p2;\n\ |
| 26463 | return a + b;\n\ |
| 26464 | }"; |
| 26465 | |
| 26466 | double (*proc)(double a, unsigned char b); |
| 26467 | cod_parse_context context = new_cod_parse_context(); |
| 26468 | int dumped = 0; |
| 26469 | |
| 26470 | cod_code gen_code; |
| 26471 | |
| 26472 | /* test for double + unsigned char */ |
| 26473 | if (verbose) printf("test for double + unsigned char"); |
| 26474 | |
| 26475 | cod_assoc_externs(context, externs); |
| 26476 | cod_parse_for_context(extern_string, context); |
| 26477 | |
| 26478 | cod_subroutine_declaration("double proc(double p1, unsigned char p2)", |
| 26479 | context); |
| 26480 | gen_code = cod_code_gen(code, context); |
| 26481 | proc = (double (*)(double, unsigned char))(long)gen_code->func; |
| 26482 | |
| 26483 | |
| 26484 | for (i=0 ; i < sizeof(src1d_vals)/sizeof(src1d_vals[0]) ; i++) { |
| 26485 | double source1_d = src1d_vals[i]; |
| 26486 | for (j=0 ; j < sizeof(src2uc_vals)/sizeof(src2uc_vals[0]) ; j++) { |
| 26487 | unsigned char source2_uc = src2uc_vals[j]; |
| 26488 | |
| 26489 | double expected_result; |
| 26490 | double result; |
| 26491 | |
| 26492 | |
| 26493 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 26494 | |
| 26495 | expected_result = (double) (source1_d + source2_uc); |
| 26496 | |
| 26497 | result = proc(source1_d, source2_uc); |
| 26498 | if (expected_result != result) { |
| 26499 | printf("Failed double + unsigned char test, expected %g, got %g, for %g + %u\n", |
| 26500 | expected_result, result, source1_d, source2_uc); |
| 26501 | if (dumped == 0) cod_dump(gen_code); |
| 26502 | failed++; |
| 26503 | dumped++; |
| 26504 | } |
| 26505 | } |
| 26506 | } |
| 26507 | if (verbose) printf(" done\n"); |
| 26508 | cod_free_parse_context(context); |
| 26509 | cod_code_free(gen_code); |
| 26510 | } |
| 26511 | if ((only_run_test == NULL((void*)0)) || |
| 26512 | (strcmp(only_run_test, "d+s") == 0)) { |
| 26513 | int i, j; |
| 26514 | static char code[] = "{\n\ |
| 26515 | double a = p1;\n\ |
| 26516 | short b = p2;\n\ |
| 26517 | return a + b;\n\ |
| 26518 | }"; |
| 26519 | |
| 26520 | double (*proc)(double a, short b); |
| 26521 | cod_parse_context context = new_cod_parse_context(); |
| 26522 | int dumped = 0; |
| 26523 | |
| 26524 | cod_code gen_code; |
| 26525 | |
| 26526 | /* test for double + short */ |
| 26527 | if (verbose) printf("test for double + short"); |
| 26528 | |
| 26529 | cod_assoc_externs(context, externs); |
| 26530 | cod_parse_for_context(extern_string, context); |
| 26531 | |
| 26532 | cod_subroutine_declaration("double proc(double p1, short p2)", |
| 26533 | context); |
| 26534 | gen_code = cod_code_gen(code, context); |
| 26535 | proc = (double (*)(double, short))(long)gen_code->func; |
| 26536 | |
| 26537 | |
| 26538 | for (i=0 ; i < sizeof(src1d_vals)/sizeof(src1d_vals[0]) ; i++) { |
| 26539 | double source1_d = src1d_vals[i]; |
| 26540 | for (j=0 ; j < sizeof(src2s_vals)/sizeof(src2s_vals[0]) ; j++) { |
| 26541 | short source2_s = src2s_vals[j]; |
| 26542 | |
| 26543 | double expected_result; |
| 26544 | double result; |
| 26545 | |
| 26546 | |
| 26547 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 26548 | |
| 26549 | expected_result = (double) (source1_d + source2_s); |
| 26550 | |
| 26551 | result = proc(source1_d, source2_s); |
| 26552 | if (expected_result != result) { |
| 26553 | printf("Failed double + short test, expected %g, got %g, for %g + %d\n", |
| 26554 | expected_result, result, source1_d, source2_s); |
| 26555 | if (dumped == 0) cod_dump(gen_code); |
| 26556 | failed++; |
| 26557 | dumped++; |
| 26558 | } |
| 26559 | } |
| 26560 | } |
| 26561 | if (verbose) printf(" done\n"); |
| 26562 | cod_free_parse_context(context); |
| 26563 | cod_code_free(gen_code); |
| 26564 | } |
| 26565 | if ((only_run_test == NULL((void*)0)) || |
| 26566 | (strcmp(only_run_test, "d+us") == 0)) { |
| 26567 | int i, j; |
| 26568 | static char code[] = "{\n\ |
| 26569 | double a = p1;\n\ |
| 26570 | unsigned short b = p2;\n\ |
| 26571 | return a + b;\n\ |
| 26572 | }"; |
| 26573 | |
| 26574 | double (*proc)(double a, unsigned short b); |
| 26575 | cod_parse_context context = new_cod_parse_context(); |
| 26576 | int dumped = 0; |
| 26577 | |
| 26578 | cod_code gen_code; |
| 26579 | |
| 26580 | /* test for double + unsigned short */ |
| 26581 | if (verbose) printf("test for double + unsigned short"); |
| 26582 | |
| 26583 | cod_assoc_externs(context, externs); |
| 26584 | cod_parse_for_context(extern_string, context); |
| 26585 | |
| 26586 | cod_subroutine_declaration("double proc(double p1, unsigned short p2)", |
| 26587 | context); |
| 26588 | gen_code = cod_code_gen(code, context); |
| 26589 | proc = (double (*)(double, unsigned short))(long)gen_code->func; |
| 26590 | |
| 26591 | |
| 26592 | for (i=0 ; i < sizeof(src1d_vals)/sizeof(src1d_vals[0]) ; i++) { |
| 26593 | double source1_d = src1d_vals[i]; |
| 26594 | for (j=0 ; j < sizeof(src2us_vals)/sizeof(src2us_vals[0]) ; j++) { |
| 26595 | unsigned short source2_us = src2us_vals[j]; |
| 26596 | |
| 26597 | double expected_result; |
| 26598 | double result; |
| 26599 | |
| 26600 | |
| 26601 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 26602 | |
| 26603 | expected_result = (double) (source1_d + source2_us); |
| 26604 | |
| 26605 | result = proc(source1_d, source2_us); |
| 26606 | if (expected_result != result) { |
| 26607 | printf("Failed double + unsigned short test, expected %g, got %g, for %g + %u\n", |
| 26608 | expected_result, result, source1_d, source2_us); |
| 26609 | if (dumped == 0) cod_dump(gen_code); |
| 26610 | failed++; |
| 26611 | dumped++; |
| 26612 | } |
| 26613 | } |
| 26614 | } |
| 26615 | if (verbose) printf(" done\n"); |
| 26616 | cod_free_parse_context(context); |
| 26617 | cod_code_free(gen_code); |
| 26618 | } |
| 26619 | if ((only_run_test == NULL((void*)0)) || |
| 26620 | (strcmp(only_run_test, "d+i") == 0)) { |
| 26621 | int i, j; |
| 26622 | static char code[] = "{\n\ |
| 26623 | double a = p1;\n\ |
| 26624 | int b = p2;\n\ |
| 26625 | return a + b;\n\ |
| 26626 | }"; |
| 26627 | |
| 26628 | double (*proc)(double a, int b); |
| 26629 | cod_parse_context context = new_cod_parse_context(); |
| 26630 | int dumped = 0; |
| 26631 | |
| 26632 | cod_code gen_code; |
| 26633 | |
| 26634 | /* test for double + int */ |
| 26635 | if (verbose) printf("test for double + int"); |
| 26636 | |
| 26637 | cod_assoc_externs(context, externs); |
| 26638 | cod_parse_for_context(extern_string, context); |
| 26639 | |
| 26640 | cod_subroutine_declaration("double proc(double p1, int p2)", |
| 26641 | context); |
| 26642 | gen_code = cod_code_gen(code, context); |
| 26643 | proc = (double (*)(double, int))(long)gen_code->func; |
| 26644 | |
| 26645 | |
| 26646 | for (i=0 ; i < sizeof(src1d_vals)/sizeof(src1d_vals[0]) ; i++) { |
| 26647 | double source1_d = src1d_vals[i]; |
| 26648 | for (j=0 ; j < sizeof(src2i_vals)/sizeof(src2i_vals[0]) ; j++) { |
| 26649 | int source2_i = src2i_vals[j]; |
| 26650 | |
| 26651 | double expected_result; |
| 26652 | double result; |
| 26653 | |
| 26654 | |
| 26655 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 26656 | |
| 26657 | expected_result = (double) (source1_d + source2_i); |
| 26658 | |
| 26659 | result = proc(source1_d, source2_i); |
| 26660 | if (expected_result != result) { |
| 26661 | printf("Failed double + int test, expected %g, got %g, for %g + %d\n", |
| 26662 | expected_result, result, source1_d, source2_i); |
| 26663 | if (dumped == 0) cod_dump(gen_code); |
| 26664 | failed++; |
| 26665 | dumped++; |
| 26666 | } |
| 26667 | } |
| 26668 | } |
| 26669 | if (verbose) printf(" done\n"); |
| 26670 | cod_free_parse_context(context); |
| 26671 | cod_code_free(gen_code); |
| 26672 | } |
| 26673 | if ((only_run_test == NULL((void*)0)) || |
| 26674 | (strcmp(only_run_test, "d+u") == 0)) { |
| 26675 | int i, j; |
| 26676 | static char code[] = "{\n\ |
| 26677 | double a = p1;\n\ |
| 26678 | unsigned int b = p2;\n\ |
| 26679 | return a + b;\n\ |
| 26680 | }"; |
| 26681 | |
| 26682 | double (*proc)(double a, unsigned int b); |
| 26683 | cod_parse_context context = new_cod_parse_context(); |
| 26684 | int dumped = 0; |
| 26685 | |
| 26686 | cod_code gen_code; |
| 26687 | |
| 26688 | /* test for double + unsigned int */ |
| 26689 | if (verbose) printf("test for double + unsigned int"); |
| 26690 | |
| 26691 | cod_assoc_externs(context, externs); |
| 26692 | cod_parse_for_context(extern_string, context); |
| 26693 | |
| 26694 | cod_subroutine_declaration("double proc(double p1, unsigned int p2)", |
| 26695 | context); |
| 26696 | gen_code = cod_code_gen(code, context); |
| 26697 | proc = (double (*)(double, unsigned int))(long)gen_code->func; |
| 26698 | |
| 26699 | |
| 26700 | for (i=0 ; i < sizeof(src1d_vals)/sizeof(src1d_vals[0]) ; i++) { |
| 26701 | double source1_d = src1d_vals[i]; |
| 26702 | for (j=0 ; j < sizeof(src2u_vals)/sizeof(src2u_vals[0]) ; j++) { |
| 26703 | unsigned int source2_u = src2u_vals[j]; |
| 26704 | |
| 26705 | double expected_result; |
| 26706 | double result; |
| 26707 | |
| 26708 | |
| 26709 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 26710 | |
| 26711 | expected_result = (double) (source1_d + source2_u); |
| 26712 | |
| 26713 | result = proc(source1_d, source2_u); |
| 26714 | if (expected_result != result) { |
| 26715 | printf("Failed double + unsigned int test, expected %g, got %g, for %g + %u\n", |
| 26716 | expected_result, result, source1_d, source2_u); |
| 26717 | if (dumped == 0) cod_dump(gen_code); |
| 26718 | failed++; |
| 26719 | dumped++; |
| 26720 | } |
| 26721 | } |
| 26722 | } |
| 26723 | if (verbose) printf(" done\n"); |
| 26724 | cod_free_parse_context(context); |
| 26725 | cod_code_free(gen_code); |
| 26726 | } |
| 26727 | if ((only_run_test == NULL((void*)0)) || |
| 26728 | (strcmp(only_run_test, "d+ul") == 0)) { |
| 26729 | int i, j; |
| 26730 | static char code[] = "{\n\ |
| 26731 | double a = p1;\n\ |
| 26732 | unsigned long b = p2;\n\ |
| 26733 | return a + b;\n\ |
| 26734 | }"; |
| 26735 | |
| 26736 | double (*proc)(double a, unsigned long b); |
| 26737 | cod_parse_context context = new_cod_parse_context(); |
| 26738 | int dumped = 0; |
| 26739 | |
| 26740 | cod_code gen_code; |
| 26741 | |
| 26742 | /* test for double + unsigned long */ |
| 26743 | if (verbose) printf("test for double + unsigned long"); |
| 26744 | |
| 26745 | cod_assoc_externs(context, externs); |
| 26746 | cod_parse_for_context(extern_string, context); |
| 26747 | |
| 26748 | cod_subroutine_declaration("double proc(double p1, unsigned long p2)", |
| 26749 | context); |
| 26750 | gen_code = cod_code_gen(code, context); |
| 26751 | proc = (double (*)(double, unsigned long))(long)gen_code->func; |
| 26752 | |
| 26753 | |
| 26754 | for (i=0 ; i < sizeof(src1d_vals)/sizeof(src1d_vals[0]) ; i++) { |
| 26755 | double source1_d = src1d_vals[i]; |
| 26756 | for (j=0 ; j < sizeof(src2ul_vals)/sizeof(src2ul_vals[0]) ; j++) { |
| 26757 | unsigned long source2_ul = src2ul_vals[j]; |
| 26758 | |
| 26759 | double expected_result; |
| 26760 | double result; |
| 26761 | |
| 26762 | |
| 26763 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 26764 | |
| 26765 | expected_result = (double) (source1_d + source2_ul); |
| 26766 | |
| 26767 | result = proc(source1_d, source2_ul); |
| 26768 | if (expected_result != result) { |
| 26769 | printf("Failed double + unsigned long test, expected %g, got %g, for %g + %lu\n", |
| 26770 | expected_result, result, source1_d, source2_ul); |
| 26771 | if (dumped == 0) cod_dump(gen_code); |
| 26772 | failed++; |
| 26773 | dumped++; |
| 26774 | } |
| 26775 | } |
| 26776 | } |
| 26777 | if (verbose) printf(" done\n"); |
| 26778 | cod_free_parse_context(context); |
| 26779 | cod_code_free(gen_code); |
| 26780 | } |
| 26781 | if ((only_run_test == NULL((void*)0)) || |
| 26782 | (strcmp(only_run_test, "d+l") == 0)) { |
| 26783 | int i, j; |
| 26784 | static char code[] = "{\n\ |
| 26785 | double a = p1;\n\ |
| 26786 | long b = p2;\n\ |
| 26787 | return a + b;\n\ |
| 26788 | }"; |
| 26789 | |
| 26790 | double (*proc)(double a, long b); |
| 26791 | cod_parse_context context = new_cod_parse_context(); |
| 26792 | int dumped = 0; |
| 26793 | |
| 26794 | cod_code gen_code; |
| 26795 | |
| 26796 | /* test for double + long */ |
| 26797 | if (verbose) printf("test for double + long"); |
| 26798 | |
| 26799 | cod_assoc_externs(context, externs); |
| 26800 | cod_parse_for_context(extern_string, context); |
| 26801 | |
| 26802 | cod_subroutine_declaration("double proc(double p1, long p2)", |
| 26803 | context); |
| 26804 | gen_code = cod_code_gen(code, context); |
| 26805 | proc = (double (*)(double, long))(long)gen_code->func; |
| 26806 | |
| 26807 | |
| 26808 | for (i=0 ; i < sizeof(src1d_vals)/sizeof(src1d_vals[0]) ; i++) { |
| 26809 | double source1_d = src1d_vals[i]; |
| 26810 | for (j=0 ; j < sizeof(src2l_vals)/sizeof(src2l_vals[0]) ; j++) { |
| 26811 | long source2_l = src2l_vals[j]; |
| 26812 | |
| 26813 | double expected_result; |
| 26814 | double result; |
| 26815 | |
| 26816 | |
| 26817 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 26818 | |
| 26819 | expected_result = (double) (source1_d + source2_l); |
| 26820 | |
| 26821 | result = proc(source1_d, source2_l); |
| 26822 | if (expected_result != result) { |
| 26823 | printf("Failed double + long test, expected %g, got %g, for %g + %ld\n", |
| 26824 | expected_result, result, source1_d, source2_l); |
| 26825 | if (dumped == 0) cod_dump(gen_code); |
| 26826 | failed++; |
| 26827 | dumped++; |
| 26828 | } |
| 26829 | } |
| 26830 | } |
| 26831 | if (verbose) printf(" done\n"); |
| 26832 | cod_free_parse_context(context); |
| 26833 | cod_code_free(gen_code); |
| 26834 | } |
| 26835 | if ((only_run_test == NULL((void*)0)) || |
| 26836 | (strcmp(only_run_test, "d+f") == 0)) { |
| 26837 | int i, j; |
| 26838 | static char code[] = "{\n\ |
| 26839 | double a = p1;\n\ |
| 26840 | float b = p2;\n\ |
| 26841 | return a + b;\n\ |
| 26842 | }"; |
| 26843 | |
| 26844 | double (*proc)(double a, float b); |
| 26845 | cod_parse_context context = new_cod_parse_context(); |
| 26846 | int dumped = 0; |
| 26847 | |
| 26848 | cod_code gen_code; |
| 26849 | |
| 26850 | /* test for double + float */ |
| 26851 | if (verbose) printf("test for double + float"); |
| 26852 | |
| 26853 | cod_assoc_externs(context, externs); |
| 26854 | cod_parse_for_context(extern_string, context); |
| 26855 | |
| 26856 | cod_subroutine_declaration("double proc(double p1, float p2)", |
| 26857 | context); |
| 26858 | gen_code = cod_code_gen(code, context); |
| 26859 | proc = (double (*)(double, float))(long)gen_code->func; |
| 26860 | |
| 26861 | |
| 26862 | for (i=0 ; i < sizeof(src1d_vals)/sizeof(src1d_vals[0]) ; i++) { |
| 26863 | double source1_d = src1d_vals[i]; |
| 26864 | for (j=0 ; j < sizeof(src2f_vals)/sizeof(src2f_vals[0]) ; j++) { |
| 26865 | float source2_f = src2f_vals[j]; |
| 26866 | double range = 0.000001 * (fabs((double)source1_d) + fabs((double)source2_f)); |
| 26867 | double expected_result; |
| 26868 | double result; |
| 26869 | |
| 26870 | |
| 26871 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 26872 | |
| 26873 | expected_result = (double) (source1_d + source2_f); |
| 26874 | |
| 26875 | result = proc(source1_d, source2_f); |
| 26876 | range += 1.0; |
| 26877 | if ((result > (expected_result + range)) || (result < (expected_result - range))) { |
| 26878 | printf("Failed double + float test, expected %g, got %g, for %g + %g\n", |
| 26879 | expected_result, result, source1_d, source2_f); |
| 26880 | if (dumped == 0) cod_dump(gen_code); |
| 26881 | failed++; |
| 26882 | dumped++; |
| 26883 | } |
| 26884 | } |
| 26885 | } |
| 26886 | if (verbose) printf(" done\n"); |
| 26887 | cod_free_parse_context(context); |
| 26888 | cod_code_free(gen_code); |
| 26889 | } |
| 26890 | if ((only_run_test == NULL((void*)0)) || |
| 26891 | (strcmp(only_run_test, "d+d") == 0)) { |
| 26892 | int i, j; |
| 26893 | static char code[] = "{\n\ |
| 26894 | double a = p1;\n\ |
| 26895 | double b = p2;\n\ |
| 26896 | return a + b;\n\ |
| 26897 | }"; |
| 26898 | |
| 26899 | double (*proc)(double a, double b); |
| 26900 | cod_parse_context context = new_cod_parse_context(); |
| 26901 | int dumped = 0; |
| 26902 | |
| 26903 | cod_code gen_code; |
| 26904 | |
| 26905 | /* test for double + double */ |
| 26906 | if (verbose) printf("test for double + double"); |
| 26907 | |
| 26908 | cod_assoc_externs(context, externs); |
| 26909 | cod_parse_for_context(extern_string, context); |
| 26910 | |
| 26911 | cod_subroutine_declaration("double proc(double p1, double p2)", |
| 26912 | context); |
| 26913 | gen_code = cod_code_gen(code, context); |
| 26914 | proc = (double (*)(double, double))(long)gen_code->func; |
| 26915 | |
| 26916 | |
| 26917 | for (i=0 ; i < sizeof(src1d_vals)/sizeof(src1d_vals[0]) ; i++) { |
| 26918 | double source1_d = src1d_vals[i]; |
| 26919 | for (j=0 ; j < sizeof(src2d_vals)/sizeof(src2d_vals[0]) ; j++) { |
| 26920 | double source2_d = src2d_vals[j]; |
| 26921 | |
| 26922 | double expected_result; |
| 26923 | double result; |
| 26924 | |
| 26925 | |
| 26926 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 26927 | |
| 26928 | expected_result = (double) (source1_d + source2_d); |
| 26929 | |
| 26930 | result = proc(source1_d, source2_d); |
| 26931 | if (expected_result != result) { |
| 26932 | printf("Failed double + double test, expected %g, got %g, for %g + %g\n", |
| 26933 | expected_result, result, source1_d, source2_d); |
| 26934 | if (dumped == 0) cod_dump(gen_code); |
| 26935 | failed++; |
| 26936 | dumped++; |
| 26937 | } |
| 26938 | } |
| 26939 | } |
| 26940 | if (verbose) printf(" done\n"); |
| 26941 | cod_free_parse_context(context); |
| 26942 | cod_code_free(gen_code); |
| 26943 | } |
| 26944 | } |
| 26945 | void sub_c_tests() |
| 26946 | { |
| 26947 | if ((only_run_test == NULL((void*)0)) || |
| 26948 | (strcmp(only_run_test, "c-c") == 0)) { |
| 26949 | int i, j; |
| 26950 | static char code[] = "{\n\ |
| 26951 | signed char a = p1;\n\ |
| 26952 | signed char b = p2;\n\ |
| 26953 | return a - b;\n\ |
| 26954 | }"; |
| 26955 | |
| 26956 | signed char (*proc)(signed char a, signed char b); |
| 26957 | cod_parse_context context = new_cod_parse_context(); |
| 26958 | int dumped = 0; |
| 26959 | |
| 26960 | cod_code gen_code; |
| 26961 | |
| 26962 | /* test for signed char - signed char */ |
| 26963 | if (verbose) printf("test for signed char - signed char"); |
| 26964 | |
| 26965 | cod_assoc_externs(context, externs); |
| 26966 | cod_parse_for_context(extern_string, context); |
| 26967 | |
| 26968 | cod_subroutine_declaration("signed char proc(signed char p1, signed char p2)", |
| 26969 | context); |
| 26970 | gen_code = cod_code_gen(code, context); |
| 26971 | proc = (signed char (*)(signed char, signed char))(long)gen_code->func; |
| 26972 | |
| 26973 | |
| 26974 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 26975 | signed char source1_c = src1c_vals[i]; |
| 26976 | for (j=0 ; j < sizeof(src2c_vals)/sizeof(src2c_vals[0]) ; j++) { |
| 26977 | signed char source2_c = src2c_vals[j]; |
| 26978 | |
| 26979 | signed char expected_result; |
| 26980 | signed char result; |
| 26981 | |
| 26982 | |
| 26983 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 26984 | |
| 26985 | expected_result = (signed char) (source1_c - source2_c); |
| 26986 | |
| 26987 | result = proc(source1_c, source2_c); |
| 26988 | if (expected_result != result) { |
| 26989 | printf("Failed signed char - signed char test, expected %d, got %d, for %d - %d\n", |
| 26990 | expected_result, result, source1_c, source2_c); |
| 26991 | if (dumped == 0) cod_dump(gen_code); |
| 26992 | failed++; |
| 26993 | dumped++; |
| 26994 | } |
| 26995 | } |
| 26996 | } |
| 26997 | if (verbose) printf(" done\n"); |
| 26998 | cod_free_parse_context(context); |
| 26999 | cod_code_free(gen_code); |
| 27000 | } |
| 27001 | if ((only_run_test == NULL((void*)0)) || |
| 27002 | (strcmp(only_run_test, "c-uc") == 0)) { |
| 27003 | int i, j; |
| 27004 | static char code[] = "{\n\ |
| 27005 | signed char a = p1;\n\ |
| 27006 | unsigned char b = p2;\n\ |
| 27007 | return a - b;\n\ |
| 27008 | }"; |
| 27009 | |
| 27010 | signed char (*proc)(signed char a, unsigned char b); |
| 27011 | cod_parse_context context = new_cod_parse_context(); |
| 27012 | int dumped = 0; |
| 27013 | |
| 27014 | cod_code gen_code; |
| 27015 | |
| 27016 | /* test for signed char - unsigned char */ |
| 27017 | if (verbose) printf("test for signed char - unsigned char"); |
| 27018 | |
| 27019 | cod_assoc_externs(context, externs); |
| 27020 | cod_parse_for_context(extern_string, context); |
| 27021 | |
| 27022 | cod_subroutine_declaration("signed char proc(signed char p1, unsigned char p2)", |
| 27023 | context); |
| 27024 | gen_code = cod_code_gen(code, context); |
| 27025 | proc = (signed char (*)(signed char, unsigned char))(long)gen_code->func; |
| 27026 | |
| 27027 | |
| 27028 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 27029 | signed char source1_c = src1c_vals[i]; |
| 27030 | for (j=0 ; j < sizeof(src2uc_vals)/sizeof(src2uc_vals[0]) ; j++) { |
| 27031 | unsigned char source2_uc = src2uc_vals[j]; |
| 27032 | |
| 27033 | signed char expected_result; |
| 27034 | signed char result; |
| 27035 | |
| 27036 | |
| 27037 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 27038 | |
| 27039 | expected_result = (signed char) (source1_c - source2_uc); |
| 27040 | |
| 27041 | result = proc(source1_c, source2_uc); |
| 27042 | if (expected_result != result) { |
| 27043 | printf("Failed signed char - unsigned char test, expected %d, got %d, for %d - %u\n", |
| 27044 | expected_result, result, source1_c, source2_uc); |
| 27045 | if (dumped == 0) cod_dump(gen_code); |
| 27046 | failed++; |
| 27047 | dumped++; |
| 27048 | } |
| 27049 | } |
| 27050 | } |
| 27051 | if (verbose) printf(" done\n"); |
| 27052 | cod_free_parse_context(context); |
| 27053 | cod_code_free(gen_code); |
| 27054 | } |
| 27055 | if ((only_run_test == NULL((void*)0)) || |
| 27056 | (strcmp(only_run_test, "c-s") == 0)) { |
| 27057 | int i, j; |
| 27058 | static char code[] = "{\n\ |
| 27059 | signed char a = p1;\n\ |
| 27060 | short b = p2;\n\ |
| 27061 | return a - b;\n\ |
| 27062 | }"; |
| 27063 | |
| 27064 | signed char (*proc)(signed char a, short b); |
| 27065 | cod_parse_context context = new_cod_parse_context(); |
| 27066 | int dumped = 0; |
| 27067 | |
| 27068 | cod_code gen_code; |
| 27069 | |
| 27070 | /* test for signed char - short */ |
| 27071 | if (verbose) printf("test for signed char - short"); |
| 27072 | |
| 27073 | cod_assoc_externs(context, externs); |
| 27074 | cod_parse_for_context(extern_string, context); |
| 27075 | |
| 27076 | cod_subroutine_declaration("signed char proc(signed char p1, short p2)", |
| 27077 | context); |
| 27078 | gen_code = cod_code_gen(code, context); |
| 27079 | proc = (signed char (*)(signed char, short))(long)gen_code->func; |
| 27080 | |
| 27081 | |
| 27082 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 27083 | signed char source1_c = src1c_vals[i]; |
| 27084 | for (j=0 ; j < sizeof(src2s_vals)/sizeof(src2s_vals[0]) ; j++) { |
| 27085 | short source2_s = src2s_vals[j]; |
| 27086 | |
| 27087 | signed char expected_result; |
| 27088 | signed char result; |
| 27089 | |
| 27090 | |
| 27091 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 27092 | |
| 27093 | expected_result = (signed char) (source1_c - source2_s); |
| 27094 | |
| 27095 | result = proc(source1_c, source2_s); |
| 27096 | if (expected_result != result) { |
| 27097 | printf("Failed signed char - short test, expected %d, got %d, for %d - %d\n", |
| 27098 | expected_result, result, source1_c, source2_s); |
| 27099 | if (dumped == 0) cod_dump(gen_code); |
| 27100 | failed++; |
| 27101 | dumped++; |
| 27102 | } |
| 27103 | } |
| 27104 | } |
| 27105 | if (verbose) printf(" done\n"); |
| 27106 | cod_free_parse_context(context); |
| 27107 | cod_code_free(gen_code); |
| 27108 | } |
| 27109 | if ((only_run_test == NULL((void*)0)) || |
| 27110 | (strcmp(only_run_test, "c-us") == 0)) { |
| 27111 | int i, j; |
| 27112 | static char code[] = "{\n\ |
| 27113 | signed char a = p1;\n\ |
| 27114 | unsigned short b = p2;\n\ |
| 27115 | return a - b;\n\ |
| 27116 | }"; |
| 27117 | |
| 27118 | signed char (*proc)(signed char a, unsigned short b); |
| 27119 | cod_parse_context context = new_cod_parse_context(); |
| 27120 | int dumped = 0; |
| 27121 | |
| 27122 | cod_code gen_code; |
| 27123 | |
| 27124 | /* test for signed char - unsigned short */ |
| 27125 | if (verbose) printf("test for signed char - unsigned short"); |
| 27126 | |
| 27127 | cod_assoc_externs(context, externs); |
| 27128 | cod_parse_for_context(extern_string, context); |
| 27129 | |
| 27130 | cod_subroutine_declaration("signed char proc(signed char p1, unsigned short p2)", |
| 27131 | context); |
| 27132 | gen_code = cod_code_gen(code, context); |
| 27133 | proc = (signed char (*)(signed char, unsigned short))(long)gen_code->func; |
| 27134 | |
| 27135 | |
| 27136 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 27137 | signed char source1_c = src1c_vals[i]; |
| 27138 | for (j=0 ; j < sizeof(src2us_vals)/sizeof(src2us_vals[0]) ; j++) { |
| 27139 | unsigned short source2_us = src2us_vals[j]; |
| 27140 | |
| 27141 | signed char expected_result; |
| 27142 | signed char result; |
| 27143 | |
| 27144 | |
| 27145 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 27146 | |
| 27147 | expected_result = (signed char) (source1_c - source2_us); |
| 27148 | |
| 27149 | result = proc(source1_c, source2_us); |
| 27150 | if (expected_result != result) { |
| 27151 | printf("Failed signed char - unsigned short test, expected %d, got %d, for %d - %u\n", |
| 27152 | expected_result, result, source1_c, source2_us); |
| 27153 | if (dumped == 0) cod_dump(gen_code); |
| 27154 | failed++; |
| 27155 | dumped++; |
| 27156 | } |
| 27157 | } |
| 27158 | } |
| 27159 | if (verbose) printf(" done\n"); |
| 27160 | cod_free_parse_context(context); |
| 27161 | cod_code_free(gen_code); |
| 27162 | } |
| 27163 | if ((only_run_test == NULL((void*)0)) || |
| 27164 | (strcmp(only_run_test, "c-i") == 0)) { |
| 27165 | int i, j; |
| 27166 | static char code[] = "{\n\ |
| 27167 | signed char a = p1;\n\ |
| 27168 | int b = p2;\n\ |
| 27169 | return a - b;\n\ |
| 27170 | }"; |
| 27171 | |
| 27172 | signed char (*proc)(signed char a, int b); |
| 27173 | cod_parse_context context = new_cod_parse_context(); |
| 27174 | int dumped = 0; |
| 27175 | |
| 27176 | cod_code gen_code; |
| 27177 | |
| 27178 | /* test for signed char - int */ |
| 27179 | if (verbose) printf("test for signed char - int"); |
| 27180 | |
| 27181 | cod_assoc_externs(context, externs); |
| 27182 | cod_parse_for_context(extern_string, context); |
| 27183 | |
| 27184 | cod_subroutine_declaration("signed char proc(signed char p1, int p2)", |
| 27185 | context); |
| 27186 | gen_code = cod_code_gen(code, context); |
| 27187 | proc = (signed char (*)(signed char, int))(long)gen_code->func; |
| 27188 | |
| 27189 | |
| 27190 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 27191 | signed char source1_c = src1c_vals[i]; |
| 27192 | for (j=0 ; j < sizeof(src2i_vals)/sizeof(src2i_vals[0]) ; j++) { |
| 27193 | int source2_i = src2i_vals[j]; |
| 27194 | |
| 27195 | signed char expected_result; |
| 27196 | signed char result; |
| 27197 | |
| 27198 | |
| 27199 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 27200 | |
| 27201 | expected_result = (signed char) (source1_c - source2_i); |
| 27202 | |
| 27203 | result = proc(source1_c, source2_i); |
| 27204 | if (expected_result != result) { |
| 27205 | printf("Failed signed char - int test, expected %d, got %d, for %d - %d\n", |
| 27206 | expected_result, result, source1_c, source2_i); |
| 27207 | if (dumped == 0) cod_dump(gen_code); |
| 27208 | failed++; |
| 27209 | dumped++; |
| 27210 | } |
| 27211 | } |
| 27212 | } |
| 27213 | if (verbose) printf(" done\n"); |
| 27214 | cod_free_parse_context(context); |
| 27215 | cod_code_free(gen_code); |
| 27216 | } |
| 27217 | if ((only_run_test == NULL((void*)0)) || |
| 27218 | (strcmp(only_run_test, "c-u") == 0)) { |
| 27219 | int i, j; |
| 27220 | static char code[] = "{\n\ |
| 27221 | signed char a = p1;\n\ |
| 27222 | unsigned int b = p2;\n\ |
| 27223 | return a - b;\n\ |
| 27224 | }"; |
| 27225 | |
| 27226 | signed char (*proc)(signed char a, unsigned int b); |
| 27227 | cod_parse_context context = new_cod_parse_context(); |
| 27228 | int dumped = 0; |
| 27229 | |
| 27230 | cod_code gen_code; |
| 27231 | |
| 27232 | /* test for signed char - unsigned int */ |
| 27233 | if (verbose) printf("test for signed char - unsigned int"); |
| 27234 | |
| 27235 | cod_assoc_externs(context, externs); |
| 27236 | cod_parse_for_context(extern_string, context); |
| 27237 | |
| 27238 | cod_subroutine_declaration("signed char proc(signed char p1, unsigned int p2)", |
| 27239 | context); |
| 27240 | gen_code = cod_code_gen(code, context); |
| 27241 | proc = (signed char (*)(signed char, unsigned int))(long)gen_code->func; |
| 27242 | |
| 27243 | |
| 27244 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 27245 | signed char source1_c = src1c_vals[i]; |
| 27246 | for (j=0 ; j < sizeof(src2u_vals)/sizeof(src2u_vals[0]) ; j++) { |
| 27247 | unsigned int source2_u = src2u_vals[j]; |
| 27248 | |
| 27249 | signed char expected_result; |
| 27250 | signed char result; |
| 27251 | |
| 27252 | |
| 27253 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 27254 | |
| 27255 | expected_result = (signed char) (source1_c - source2_u); |
| 27256 | |
| 27257 | result = proc(source1_c, source2_u); |
| 27258 | if (expected_result != result) { |
| 27259 | printf("Failed signed char - unsigned int test, expected %d, got %d, for %d - %u\n", |
| 27260 | expected_result, result, source1_c, source2_u); |
| 27261 | if (dumped == 0) cod_dump(gen_code); |
| 27262 | failed++; |
| 27263 | dumped++; |
| 27264 | } |
| 27265 | } |
| 27266 | } |
| 27267 | if (verbose) printf(" done\n"); |
| 27268 | cod_free_parse_context(context); |
| 27269 | cod_code_free(gen_code); |
| 27270 | } |
| 27271 | if ((only_run_test == NULL((void*)0)) || |
| 27272 | (strcmp(only_run_test, "c-ul") == 0)) { |
| 27273 | int i, j; |
| 27274 | static char code[] = "{\n\ |
| 27275 | signed char a = p1;\n\ |
| 27276 | unsigned long b = p2;\n\ |
| 27277 | return a - b;\n\ |
| 27278 | }"; |
| 27279 | |
| 27280 | signed char (*proc)(signed char a, unsigned long b); |
| 27281 | cod_parse_context context = new_cod_parse_context(); |
| 27282 | int dumped = 0; |
| 27283 | |
| 27284 | cod_code gen_code; |
| 27285 | |
| 27286 | /* test for signed char - unsigned long */ |
| 27287 | if (verbose) printf("test for signed char - unsigned long"); |
| 27288 | |
| 27289 | cod_assoc_externs(context, externs); |
| 27290 | cod_parse_for_context(extern_string, context); |
| 27291 | |
| 27292 | cod_subroutine_declaration("signed char proc(signed char p1, unsigned long p2)", |
| 27293 | context); |
| 27294 | gen_code = cod_code_gen(code, context); |
| 27295 | proc = (signed char (*)(signed char, unsigned long))(long)gen_code->func; |
| 27296 | |
| 27297 | |
| 27298 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 27299 | signed char source1_c = src1c_vals[i]; |
| 27300 | for (j=0 ; j < sizeof(src2ul_vals)/sizeof(src2ul_vals[0]) ; j++) { |
| 27301 | unsigned long source2_ul = src2ul_vals[j]; |
| 27302 | |
| 27303 | signed char expected_result; |
| 27304 | signed char result; |
| 27305 | |
| 27306 | |
| 27307 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 27308 | |
| 27309 | expected_result = (signed char) (source1_c - source2_ul); |
| 27310 | |
| 27311 | result = proc(source1_c, source2_ul); |
| 27312 | if (expected_result != result) { |
| 27313 | printf("Failed signed char - unsigned long test, expected %d, got %d, for %d - %lu\n", |
| 27314 | expected_result, result, source1_c, source2_ul); |
| 27315 | if (dumped == 0) cod_dump(gen_code); |
| 27316 | failed++; |
| 27317 | dumped++; |
| 27318 | } |
| 27319 | } |
| 27320 | } |
| 27321 | if (verbose) printf(" done\n"); |
| 27322 | cod_free_parse_context(context); |
| 27323 | cod_code_free(gen_code); |
| 27324 | } |
| 27325 | if ((only_run_test == NULL((void*)0)) || |
| 27326 | (strcmp(only_run_test, "c-l") == 0)) { |
| 27327 | int i, j; |
| 27328 | static char code[] = "{\n\ |
| 27329 | signed char a = p1;\n\ |
| 27330 | long b = p2;\n\ |
| 27331 | return a - b;\n\ |
| 27332 | }"; |
| 27333 | |
| 27334 | signed char (*proc)(signed char a, long b); |
| 27335 | cod_parse_context context = new_cod_parse_context(); |
| 27336 | int dumped = 0; |
| 27337 | |
| 27338 | cod_code gen_code; |
| 27339 | |
| 27340 | /* test for signed char - long */ |
| 27341 | if (verbose) printf("test for signed char - long"); |
| 27342 | |
| 27343 | cod_assoc_externs(context, externs); |
| 27344 | cod_parse_for_context(extern_string, context); |
| 27345 | |
| 27346 | cod_subroutine_declaration("signed char proc(signed char p1, long p2)", |
| 27347 | context); |
| 27348 | gen_code = cod_code_gen(code, context); |
| 27349 | proc = (signed char (*)(signed char, long))(long)gen_code->func; |
| 27350 | |
| 27351 | |
| 27352 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 27353 | signed char source1_c = src1c_vals[i]; |
| 27354 | for (j=0 ; j < sizeof(src2l_vals)/sizeof(src2l_vals[0]) ; j++) { |
| 27355 | long source2_l = src2l_vals[j]; |
| 27356 | |
| 27357 | signed char expected_result; |
| 27358 | signed char result; |
| 27359 | |
| 27360 | |
| 27361 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 27362 | |
| 27363 | expected_result = (signed char) (source1_c - source2_l); |
| 27364 | |
| 27365 | result = proc(source1_c, source2_l); |
| 27366 | if (expected_result != result) { |
| 27367 | printf("Failed signed char - long test, expected %d, got %d, for %d - %ld\n", |
| 27368 | expected_result, result, source1_c, source2_l); |
| 27369 | if (dumped == 0) cod_dump(gen_code); |
| 27370 | failed++; |
| 27371 | dumped++; |
| 27372 | } |
| 27373 | } |
| 27374 | } |
| 27375 | if (verbose) printf(" done\n"); |
| 27376 | cod_free_parse_context(context); |
| 27377 | cod_code_free(gen_code); |
| 27378 | } |
| 27379 | if ((only_run_test == NULL((void*)0)) || |
| 27380 | (strcmp(only_run_test, "c-f") == 0)) { |
| 27381 | int i, j; |
| 27382 | static char code[] = "{\n\ |
| 27383 | signed char a = p1;\n\ |
| 27384 | float b = p2;\n\ |
| 27385 | return a - b;\n\ |
| 27386 | }"; |
| 27387 | |
| 27388 | signed char (*proc)(signed char a, float b); |
| 27389 | cod_parse_context context = new_cod_parse_context(); |
| 27390 | int dumped = 0; |
| 27391 | |
| 27392 | cod_code gen_code; |
| 27393 | |
| 27394 | /* test for signed char - float */ |
| 27395 | if (verbose) printf("test for signed char - float"); |
| 27396 | |
| 27397 | cod_assoc_externs(context, externs); |
| 27398 | cod_parse_for_context(extern_string, context); |
| 27399 | |
| 27400 | cod_subroutine_declaration("signed char proc(signed char p1, float p2)", |
| 27401 | context); |
| 27402 | gen_code = cod_code_gen(code, context); |
| 27403 | proc = (signed char (*)(signed char, float))(long)gen_code->func; |
| 27404 | |
| 27405 | |
| 27406 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 27407 | signed char source1_c = src1c_vals[i]; |
| 27408 | for (j=0 ; j < sizeof(src2f_vals)/sizeof(src2f_vals[0]) ; j++) { |
| 27409 | float source2_f = src2f_vals[j]; |
| 27410 | double range = 0.000001 * (fabs((double)source1_c) + fabs((double)source2_f)); |
| 27411 | signed char expected_result; |
| 27412 | signed char result; |
| 27413 | |
| 27414 | |
| 27415 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 27416 | |
| 27417 | expected_result = (signed char) (source1_c - source2_f); |
| 27418 | |
| 27419 | result = proc(source1_c, source2_f); |
| 27420 | range += 1.0; |
| 27421 | if ((result > (expected_result + range)) || (result < (expected_result - range))) { |
| 27422 | printf("Failed signed char - float test, expected %d, got %d, for %d - %g\n", |
| 27423 | expected_result, result, source1_c, source2_f); |
| 27424 | if (dumped == 0) cod_dump(gen_code); |
| 27425 | failed++; |
| 27426 | dumped++; |
| 27427 | } |
| 27428 | } |
| 27429 | } |
| 27430 | if (verbose) printf(" done\n"); |
| 27431 | cod_free_parse_context(context); |
| 27432 | cod_code_free(gen_code); |
| 27433 | } |
| 27434 | if ((only_run_test == NULL((void*)0)) || |
| 27435 | (strcmp(only_run_test, "c-d") == 0)) { |
| 27436 | int i, j; |
| 27437 | static char code[] = "{\n\ |
| 27438 | signed char a = p1;\n\ |
| 27439 | double b = p2;\n\ |
| 27440 | return a - b;\n\ |
| 27441 | }"; |
| 27442 | |
| 27443 | signed char (*proc)(signed char a, double b); |
| 27444 | cod_parse_context context = new_cod_parse_context(); |
| 27445 | int dumped = 0; |
| 27446 | |
| 27447 | cod_code gen_code; |
| 27448 | |
| 27449 | /* test for signed char - double */ |
| 27450 | if (verbose) printf("test for signed char - double"); |
| 27451 | |
| 27452 | cod_assoc_externs(context, externs); |
| 27453 | cod_parse_for_context(extern_string, context); |
| 27454 | |
| 27455 | cod_subroutine_declaration("signed char proc(signed char p1, double p2)", |
| 27456 | context); |
| 27457 | gen_code = cod_code_gen(code, context); |
| 27458 | proc = (signed char (*)(signed char, double))(long)gen_code->func; |
| 27459 | |
| 27460 | |
| 27461 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 27462 | signed char source1_c = src1c_vals[i]; |
| 27463 | for (j=0 ; j < sizeof(src2d_vals)/sizeof(src2d_vals[0]) ; j++) { |
| 27464 | double source2_d = src2d_vals[j]; |
| 27465 | |
| 27466 | signed char expected_result; |
| 27467 | signed char result; |
| 27468 | |
| 27469 | |
| 27470 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 27471 | |
| 27472 | expected_result = (signed char) (source1_c - source2_d); |
| 27473 | |
| 27474 | result = proc(source1_c, source2_d); |
| 27475 | if (expected_result != result) { |
| 27476 | printf("Failed signed char - double test, expected %d, got %d, for %d - %g\n", |
| 27477 | expected_result, result, source1_c, source2_d); |
| 27478 | if (dumped == 0) cod_dump(gen_code); |
| 27479 | failed++; |
| 27480 | dumped++; |
| 27481 | } |
| 27482 | } |
| 27483 | } |
| 27484 | if (verbose) printf(" done\n"); |
| 27485 | cod_free_parse_context(context); |
| 27486 | cod_code_free(gen_code); |
| 27487 | } |
| 27488 | } |
| 27489 | void sub_uc_tests() |
| 27490 | { |
| 27491 | if ((only_run_test == NULL((void*)0)) || |
| 27492 | (strcmp(only_run_test, "uc-c") == 0)) { |
| 27493 | int i, j; |
| 27494 | static char code[] = "{\n\ |
| 27495 | unsigned char a = p1;\n\ |
| 27496 | signed char b = p2;\n\ |
| 27497 | return a - b;\n\ |
| 27498 | }"; |
| 27499 | |
| 27500 | unsigned char (*proc)(unsigned char a, signed char b); |
| 27501 | cod_parse_context context = new_cod_parse_context(); |
| 27502 | int dumped = 0; |
| 27503 | |
| 27504 | cod_code gen_code; |
| 27505 | |
| 27506 | /* test for unsigned char - signed char */ |
| 27507 | if (verbose) printf("test for unsigned char - signed char"); |
| 27508 | |
| 27509 | cod_assoc_externs(context, externs); |
| 27510 | cod_parse_for_context(extern_string, context); |
| 27511 | |
| 27512 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, signed char p2)", |
| 27513 | context); |
| 27514 | gen_code = cod_code_gen(code, context); |
| 27515 | proc = (unsigned char (*)(unsigned char, signed char))(long)gen_code->func; |
| 27516 | |
| 27517 | |
| 27518 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 27519 | unsigned char source1_uc = src1uc_vals[i]; |
| 27520 | for (j=0 ; j < sizeof(src2c_vals)/sizeof(src2c_vals[0]) ; j++) { |
| 27521 | signed char source2_c = src2c_vals[j]; |
| 27522 | |
| 27523 | unsigned char expected_result; |
| 27524 | unsigned char result; |
| 27525 | |
| 27526 | |
| 27527 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 27528 | |
| 27529 | expected_result = (unsigned char) (source1_uc - source2_c); |
| 27530 | |
| 27531 | result = proc(source1_uc, source2_c); |
| 27532 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 27533 | if (expected_result != result) { |
| 27534 | printf("Failed unsigned char - signed char test, expected %u, got %u, for %u - %d\n", |
| 27535 | expected_result, result, source1_uc, source2_c); |
| 27536 | if (dumped == 0) cod_dump(gen_code); |
| 27537 | failed++; |
| 27538 | dumped++; |
| 27539 | } |
| 27540 | } |
| 27541 | } |
| 27542 | if (verbose) printf(" done\n"); |
| 27543 | cod_free_parse_context(context); |
| 27544 | cod_code_free(gen_code); |
| 27545 | } |
| 27546 | if ((only_run_test == NULL((void*)0)) || |
| 27547 | (strcmp(only_run_test, "uc-uc") == 0)) { |
| 27548 | int i, j; |
| 27549 | static char code[] = "{\n\ |
| 27550 | unsigned char a = p1;\n\ |
| 27551 | unsigned char b = p2;\n\ |
| 27552 | return a - b;\n\ |
| 27553 | }"; |
| 27554 | |
| 27555 | unsigned char (*proc)(unsigned char a, unsigned char b); |
| 27556 | cod_parse_context context = new_cod_parse_context(); |
| 27557 | int dumped = 0; |
| 27558 | |
| 27559 | cod_code gen_code; |
| 27560 | |
| 27561 | /* test for unsigned char - unsigned char */ |
| 27562 | if (verbose) printf("test for unsigned char - unsigned char"); |
| 27563 | |
| 27564 | cod_assoc_externs(context, externs); |
| 27565 | cod_parse_for_context(extern_string, context); |
| 27566 | |
| 27567 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, unsigned char p2)", |
| 27568 | context); |
| 27569 | gen_code = cod_code_gen(code, context); |
| 27570 | proc = (unsigned char (*)(unsigned char, unsigned char))(long)gen_code->func; |
| 27571 | |
| 27572 | |
| 27573 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 27574 | unsigned char source1_uc = src1uc_vals[i]; |
| 27575 | for (j=0 ; j < sizeof(src2uc_vals)/sizeof(src2uc_vals[0]) ; j++) { |
| 27576 | unsigned char source2_uc = src2uc_vals[j]; |
| 27577 | |
| 27578 | unsigned char expected_result; |
| 27579 | unsigned char result; |
| 27580 | |
| 27581 | |
| 27582 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 27583 | |
| 27584 | expected_result = (unsigned char) (source1_uc - source2_uc); |
| 27585 | |
| 27586 | result = proc(source1_uc, source2_uc); |
| 27587 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 27588 | if (expected_result != result) { |
| 27589 | printf("Failed unsigned char - unsigned char test, expected %u, got %u, for %u - %u\n", |
| 27590 | expected_result, result, source1_uc, source2_uc); |
| 27591 | if (dumped == 0) cod_dump(gen_code); |
| 27592 | failed++; |
| 27593 | dumped++; |
| 27594 | } |
| 27595 | } |
| 27596 | } |
| 27597 | if (verbose) printf(" done\n"); |
| 27598 | cod_free_parse_context(context); |
| 27599 | cod_code_free(gen_code); |
| 27600 | } |
| 27601 | if ((only_run_test == NULL((void*)0)) || |
| 27602 | (strcmp(only_run_test, "uc-s") == 0)) { |
| 27603 | int i, j; |
| 27604 | static char code[] = "{\n\ |
| 27605 | unsigned char a = p1;\n\ |
| 27606 | short b = p2;\n\ |
| 27607 | return a - b;\n\ |
| 27608 | }"; |
| 27609 | |
| 27610 | unsigned char (*proc)(unsigned char a, short b); |
| 27611 | cod_parse_context context = new_cod_parse_context(); |
| 27612 | int dumped = 0; |
| 27613 | |
| 27614 | cod_code gen_code; |
| 27615 | |
| 27616 | /* test for unsigned char - short */ |
| 27617 | if (verbose) printf("test for unsigned char - short"); |
| 27618 | |
| 27619 | cod_assoc_externs(context, externs); |
| 27620 | cod_parse_for_context(extern_string, context); |
| 27621 | |
| 27622 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, short p2)", |
| 27623 | context); |
| 27624 | gen_code = cod_code_gen(code, context); |
| 27625 | proc = (unsigned char (*)(unsigned char, short))(long)gen_code->func; |
| 27626 | |
| 27627 | |
| 27628 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 27629 | unsigned char source1_uc = src1uc_vals[i]; |
| 27630 | for (j=0 ; j < sizeof(src2s_vals)/sizeof(src2s_vals[0]) ; j++) { |
| 27631 | short source2_s = src2s_vals[j]; |
| 27632 | |
| 27633 | unsigned char expected_result; |
| 27634 | unsigned char result; |
| 27635 | |
| 27636 | |
| 27637 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 27638 | |
| 27639 | expected_result = (unsigned char) (source1_uc - source2_s); |
| 27640 | |
| 27641 | result = proc(source1_uc, source2_s); |
| 27642 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 27643 | if (expected_result != result) { |
| 27644 | printf("Failed unsigned char - short test, expected %u, got %u, for %u - %d\n", |
| 27645 | expected_result, result, source1_uc, source2_s); |
| 27646 | if (dumped == 0) cod_dump(gen_code); |
| 27647 | failed++; |
| 27648 | dumped++; |
| 27649 | } |
| 27650 | } |
| 27651 | } |
| 27652 | if (verbose) printf(" done\n"); |
| 27653 | cod_free_parse_context(context); |
| 27654 | cod_code_free(gen_code); |
| 27655 | } |
| 27656 | if ((only_run_test == NULL((void*)0)) || |
| 27657 | (strcmp(only_run_test, "uc-us") == 0)) { |
| 27658 | int i, j; |
| 27659 | static char code[] = "{\n\ |
| 27660 | unsigned char a = p1;\n\ |
| 27661 | unsigned short b = p2;\n\ |
| 27662 | return a - b;\n\ |
| 27663 | }"; |
| 27664 | |
| 27665 | unsigned char (*proc)(unsigned char a, unsigned short b); |
| 27666 | cod_parse_context context = new_cod_parse_context(); |
| 27667 | int dumped = 0; |
| 27668 | |
| 27669 | cod_code gen_code; |
| 27670 | |
| 27671 | /* test for unsigned char - unsigned short */ |
| 27672 | if (verbose) printf("test for unsigned char - unsigned short"); |
| 27673 | |
| 27674 | cod_assoc_externs(context, externs); |
| 27675 | cod_parse_for_context(extern_string, context); |
| 27676 | |
| 27677 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, unsigned short p2)", |
| 27678 | context); |
| 27679 | gen_code = cod_code_gen(code, context); |
| 27680 | proc = (unsigned char (*)(unsigned char, unsigned short))(long)gen_code->func; |
| 27681 | |
| 27682 | |
| 27683 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 27684 | unsigned char source1_uc = src1uc_vals[i]; |
| 27685 | for (j=0 ; j < sizeof(src2us_vals)/sizeof(src2us_vals[0]) ; j++) { |
| 27686 | unsigned short source2_us = src2us_vals[j]; |
| 27687 | |
| 27688 | unsigned char expected_result; |
| 27689 | unsigned char result; |
| 27690 | |
| 27691 | |
| 27692 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 27693 | |
| 27694 | expected_result = (unsigned char) (source1_uc - source2_us); |
| 27695 | |
| 27696 | result = proc(source1_uc, source2_us); |
| 27697 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 27698 | if (expected_result != result) { |
| 27699 | printf("Failed unsigned char - unsigned short test, expected %u, got %u, for %u - %u\n", |
| 27700 | expected_result, result, source1_uc, source2_us); |
| 27701 | if (dumped == 0) cod_dump(gen_code); |
| 27702 | failed++; |
| 27703 | dumped++; |
| 27704 | } |
| 27705 | } |
| 27706 | } |
| 27707 | if (verbose) printf(" done\n"); |
| 27708 | cod_free_parse_context(context); |
| 27709 | cod_code_free(gen_code); |
| 27710 | } |
| 27711 | if ((only_run_test == NULL((void*)0)) || |
| 27712 | (strcmp(only_run_test, "uc-i") == 0)) { |
| 27713 | int i, j; |
| 27714 | static char code[] = "{\n\ |
| 27715 | unsigned char a = p1;\n\ |
| 27716 | int b = p2;\n\ |
| 27717 | return a - b;\n\ |
| 27718 | }"; |
| 27719 | |
| 27720 | unsigned char (*proc)(unsigned char a, int b); |
| 27721 | cod_parse_context context = new_cod_parse_context(); |
| 27722 | int dumped = 0; |
| 27723 | |
| 27724 | cod_code gen_code; |
| 27725 | |
| 27726 | /* test for unsigned char - int */ |
| 27727 | if (verbose) printf("test for unsigned char - int"); |
| 27728 | |
| 27729 | cod_assoc_externs(context, externs); |
| 27730 | cod_parse_for_context(extern_string, context); |
| 27731 | |
| 27732 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, int p2)", |
| 27733 | context); |
| 27734 | gen_code = cod_code_gen(code, context); |
| 27735 | proc = (unsigned char (*)(unsigned char, int))(long)gen_code->func; |
| 27736 | |
| 27737 | |
| 27738 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 27739 | unsigned char source1_uc = src1uc_vals[i]; |
| 27740 | for (j=0 ; j < sizeof(src2i_vals)/sizeof(src2i_vals[0]) ; j++) { |
| 27741 | int source2_i = src2i_vals[j]; |
| 27742 | |
| 27743 | unsigned char expected_result; |
| 27744 | unsigned char result; |
| 27745 | |
| 27746 | |
| 27747 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 27748 | |
| 27749 | expected_result = (unsigned char) (source1_uc - source2_i); |
| 27750 | |
| 27751 | result = proc(source1_uc, source2_i); |
| 27752 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 27753 | if (expected_result != result) { |
| 27754 | printf("Failed unsigned char - int test, expected %u, got %u, for %u - %d\n", |
| 27755 | expected_result, result, source1_uc, source2_i); |
| 27756 | if (dumped == 0) cod_dump(gen_code); |
| 27757 | failed++; |
| 27758 | dumped++; |
| 27759 | } |
| 27760 | } |
| 27761 | } |
| 27762 | if (verbose) printf(" done\n"); |
| 27763 | cod_free_parse_context(context); |
| 27764 | cod_code_free(gen_code); |
| 27765 | } |
| 27766 | if ((only_run_test == NULL((void*)0)) || |
| 27767 | (strcmp(only_run_test, "uc-u") == 0)) { |
| 27768 | int i, j; |
| 27769 | static char code[] = "{\n\ |
| 27770 | unsigned char a = p1;\n\ |
| 27771 | unsigned int b = p2;\n\ |
| 27772 | return a - b;\n\ |
| 27773 | }"; |
| 27774 | |
| 27775 | unsigned char (*proc)(unsigned char a, unsigned int b); |
| 27776 | cod_parse_context context = new_cod_parse_context(); |
| 27777 | int dumped = 0; |
| 27778 | |
| 27779 | cod_code gen_code; |
| 27780 | |
| 27781 | /* test for unsigned char - unsigned int */ |
| 27782 | if (verbose) printf("test for unsigned char - unsigned int"); |
| 27783 | |
| 27784 | cod_assoc_externs(context, externs); |
| 27785 | cod_parse_for_context(extern_string, context); |
| 27786 | |
| 27787 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, unsigned int p2)", |
| 27788 | context); |
| 27789 | gen_code = cod_code_gen(code, context); |
| 27790 | proc = (unsigned char (*)(unsigned char, unsigned int))(long)gen_code->func; |
| 27791 | |
| 27792 | |
| 27793 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 27794 | unsigned char source1_uc = src1uc_vals[i]; |
| 27795 | for (j=0 ; j < sizeof(src2u_vals)/sizeof(src2u_vals[0]) ; j++) { |
| 27796 | unsigned int source2_u = src2u_vals[j]; |
| 27797 | |
| 27798 | unsigned char expected_result; |
| 27799 | unsigned char result; |
| 27800 | |
| 27801 | |
| 27802 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 27803 | |
| 27804 | expected_result = (unsigned char) (source1_uc - source2_u); |
| 27805 | |
| 27806 | result = proc(source1_uc, source2_u); |
| 27807 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 27808 | if (expected_result != result) { |
| 27809 | printf("Failed unsigned char - unsigned int test, expected %u, got %u, for %u - %u\n", |
| 27810 | expected_result, result, source1_uc, source2_u); |
| 27811 | if (dumped == 0) cod_dump(gen_code); |
| 27812 | failed++; |
| 27813 | dumped++; |
| 27814 | } |
| 27815 | } |
| 27816 | } |
| 27817 | if (verbose) printf(" done\n"); |
| 27818 | cod_free_parse_context(context); |
| 27819 | cod_code_free(gen_code); |
| 27820 | } |
| 27821 | if ((only_run_test == NULL((void*)0)) || |
| 27822 | (strcmp(only_run_test, "uc-ul") == 0)) { |
| 27823 | int i, j; |
| 27824 | static char code[] = "{\n\ |
| 27825 | unsigned char a = p1;\n\ |
| 27826 | unsigned long b = p2;\n\ |
| 27827 | return a - b;\n\ |
| 27828 | }"; |
| 27829 | |
| 27830 | unsigned char (*proc)(unsigned char a, unsigned long b); |
| 27831 | cod_parse_context context = new_cod_parse_context(); |
| 27832 | int dumped = 0; |
| 27833 | |
| 27834 | cod_code gen_code; |
| 27835 | |
| 27836 | /* test for unsigned char - unsigned long */ |
| 27837 | if (verbose) printf("test for unsigned char - unsigned long"); |
| 27838 | |
| 27839 | cod_assoc_externs(context, externs); |
| 27840 | cod_parse_for_context(extern_string, context); |
| 27841 | |
| 27842 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, unsigned long p2)", |
| 27843 | context); |
| 27844 | gen_code = cod_code_gen(code, context); |
| 27845 | proc = (unsigned char (*)(unsigned char, unsigned long))(long)gen_code->func; |
| 27846 | |
| 27847 | |
| 27848 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 27849 | unsigned char source1_uc = src1uc_vals[i]; |
| 27850 | for (j=0 ; j < sizeof(src2ul_vals)/sizeof(src2ul_vals[0]) ; j++) { |
| 27851 | unsigned long source2_ul = src2ul_vals[j]; |
| 27852 | |
| 27853 | unsigned char expected_result; |
| 27854 | unsigned char result; |
| 27855 | |
| 27856 | |
| 27857 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 27858 | |
| 27859 | expected_result = (unsigned char) (source1_uc - source2_ul); |
| 27860 | |
| 27861 | result = proc(source1_uc, source2_ul); |
| 27862 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 27863 | if (expected_result != result) { |
| 27864 | printf("Failed unsigned char - unsigned long test, expected %u, got %u, for %u - %lu\n", |
| 27865 | expected_result, result, source1_uc, source2_ul); |
| 27866 | if (dumped == 0) cod_dump(gen_code); |
| 27867 | failed++; |
| 27868 | dumped++; |
| 27869 | } |
| 27870 | } |
| 27871 | } |
| 27872 | if (verbose) printf(" done\n"); |
| 27873 | cod_free_parse_context(context); |
| 27874 | cod_code_free(gen_code); |
| 27875 | } |
| 27876 | if ((only_run_test == NULL((void*)0)) || |
| 27877 | (strcmp(only_run_test, "uc-l") == 0)) { |
| 27878 | int i, j; |
| 27879 | static char code[] = "{\n\ |
| 27880 | unsigned char a = p1;\n\ |
| 27881 | long b = p2;\n\ |
| 27882 | return a - b;\n\ |
| 27883 | }"; |
| 27884 | |
| 27885 | unsigned char (*proc)(unsigned char a, long b); |
| 27886 | cod_parse_context context = new_cod_parse_context(); |
| 27887 | int dumped = 0; |
| 27888 | |
| 27889 | cod_code gen_code; |
| 27890 | |
| 27891 | /* test for unsigned char - long */ |
| 27892 | if (verbose) printf("test for unsigned char - long"); |
| 27893 | |
| 27894 | cod_assoc_externs(context, externs); |
| 27895 | cod_parse_for_context(extern_string, context); |
| 27896 | |
| 27897 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, long p2)", |
| 27898 | context); |
| 27899 | gen_code = cod_code_gen(code, context); |
| 27900 | proc = (unsigned char (*)(unsigned char, long))(long)gen_code->func; |
| 27901 | |
| 27902 | |
| 27903 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 27904 | unsigned char source1_uc = src1uc_vals[i]; |
| 27905 | for (j=0 ; j < sizeof(src2l_vals)/sizeof(src2l_vals[0]) ; j++) { |
| 27906 | long source2_l = src2l_vals[j]; |
| 27907 | |
| 27908 | unsigned char expected_result; |
| 27909 | unsigned char result; |
| 27910 | |
| 27911 | |
| 27912 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 27913 | |
| 27914 | expected_result = (unsigned char) (source1_uc - source2_l); |
| 27915 | |
| 27916 | result = proc(source1_uc, source2_l); |
| 27917 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 27918 | if (expected_result != result) { |
| 27919 | printf("Failed unsigned char - long test, expected %u, got %u, for %u - %ld\n", |
| 27920 | expected_result, result, source1_uc, source2_l); |
| 27921 | if (dumped == 0) cod_dump(gen_code); |
| 27922 | failed++; |
| 27923 | dumped++; |
| 27924 | } |
| 27925 | } |
| 27926 | } |
| 27927 | if (verbose) printf(" done\n"); |
| 27928 | cod_free_parse_context(context); |
| 27929 | cod_code_free(gen_code); |
| 27930 | } |
| 27931 | if ((only_run_test == NULL((void*)0)) || |
| 27932 | (strcmp(only_run_test, "uc-f") == 0)) { |
| 27933 | int i, j; |
| 27934 | static char code[] = "{\n\ |
| 27935 | unsigned char a = p1;\n\ |
| 27936 | float b = p2;\n\ |
| 27937 | return a - b;\n\ |
| 27938 | }"; |
| 27939 | |
| 27940 | unsigned char (*proc)(unsigned char a, float b); |
| 27941 | cod_parse_context context = new_cod_parse_context(); |
| 27942 | int dumped = 0; |
| 27943 | |
| 27944 | cod_code gen_code; |
| 27945 | |
| 27946 | /* test for unsigned char - float */ |
| 27947 | if (verbose) printf("test for unsigned char - float"); |
| 27948 | |
| 27949 | cod_assoc_externs(context, externs); |
| 27950 | cod_parse_for_context(extern_string, context); |
| 27951 | |
| 27952 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, float p2)", |
| 27953 | context); |
| 27954 | gen_code = cod_code_gen(code, context); |
| 27955 | proc = (unsigned char (*)(unsigned char, float))(long)gen_code->func; |
| 27956 | |
| 27957 | |
| 27958 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 27959 | unsigned char source1_uc = src1uc_vals[i]; |
| 27960 | for (j=0 ; j < sizeof(src2f_vals)/sizeof(src2f_vals[0]) ; j++) { |
| 27961 | float source2_f = src2f_vals[j]; |
| 27962 | double range = 0.000001 * (fabs((double)source1_uc) + fabs((double)source2_f)); |
| 27963 | unsigned char expected_result; |
| 27964 | unsigned char result; |
| 27965 | |
| 27966 | |
| 27967 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 27968 | |
| 27969 | expected_result = (unsigned char) (source1_uc - source2_f); |
| 27970 | |
| 27971 | result = proc(source1_uc, source2_f); |
| 27972 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 27973 | range += 1.0; |
| 27974 | if ((result > (expected_result + range)) || (result < (expected_result - range))) { |
| 27975 | printf("Failed unsigned char - float test, expected %u, got %u, for %u - %g\n", |
| 27976 | expected_result, result, source1_uc, source2_f); |
| 27977 | if (dumped == 0) cod_dump(gen_code); |
| 27978 | failed++; |
| 27979 | dumped++; |
| 27980 | } |
| 27981 | } |
| 27982 | } |
| 27983 | if (verbose) printf(" done\n"); |
| 27984 | cod_free_parse_context(context); |
| 27985 | cod_code_free(gen_code); |
| 27986 | } |
| 27987 | if ((only_run_test == NULL((void*)0)) || |
| 27988 | (strcmp(only_run_test, "uc-d") == 0)) { |
| 27989 | int i, j; |
| 27990 | static char code[] = "{\n\ |
| 27991 | unsigned char a = p1;\n\ |
| 27992 | double b = p2;\n\ |
| 27993 | return a - b;\n\ |
| 27994 | }"; |
| 27995 | |
| 27996 | unsigned char (*proc)(unsigned char a, double b); |
| 27997 | cod_parse_context context = new_cod_parse_context(); |
| 27998 | int dumped = 0; |
| 27999 | |
| 28000 | cod_code gen_code; |
| 28001 | |
| 28002 | /* test for unsigned char - double */ |
| 28003 | if (verbose) printf("test for unsigned char - double"); |
| 28004 | |
| 28005 | cod_assoc_externs(context, externs); |
| 28006 | cod_parse_for_context(extern_string, context); |
| 28007 | |
| 28008 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, double p2)", |
| 28009 | context); |
| 28010 | gen_code = cod_code_gen(code, context); |
| 28011 | proc = (unsigned char (*)(unsigned char, double))(long)gen_code->func; |
| 28012 | |
| 28013 | |
| 28014 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 28015 | unsigned char source1_uc = src1uc_vals[i]; |
| 28016 | for (j=0 ; j < sizeof(src2d_vals)/sizeof(src2d_vals[0]) ; j++) { |
| 28017 | double source2_d = src2d_vals[j]; |
| 28018 | |
| 28019 | unsigned char expected_result; |
| 28020 | unsigned char result; |
| 28021 | |
| 28022 | |
| 28023 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 28024 | |
| 28025 | expected_result = (unsigned char) (source1_uc - source2_d); |
| 28026 | |
| 28027 | result = proc(source1_uc, source2_d); |
| 28028 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 28029 | if (expected_result != result) { |
| 28030 | printf("Failed unsigned char - double test, expected %u, got %u, for %u - %g\n", |
| 28031 | expected_result, result, source1_uc, source2_d); |
| 28032 | if (dumped == 0) cod_dump(gen_code); |
| 28033 | failed++; |
| 28034 | dumped++; |
| 28035 | } |
| 28036 | } |
| 28037 | } |
| 28038 | if (verbose) printf(" done\n"); |
| 28039 | cod_free_parse_context(context); |
| 28040 | cod_code_free(gen_code); |
| 28041 | } |
| 28042 | } |
| 28043 | void sub_s_tests() |
| 28044 | { |
| 28045 | if ((only_run_test == NULL((void*)0)) || |
| 28046 | (strcmp(only_run_test, "s-c") == 0)) { |
| 28047 | int i, j; |
| 28048 | static char code[] = "{\n\ |
| 28049 | short a = p1;\n\ |
| 28050 | signed char b = p2;\n\ |
| 28051 | return a - b;\n\ |
| 28052 | }"; |
| 28053 | |
| 28054 | short (*proc)(short a, signed char b); |
| 28055 | cod_parse_context context = new_cod_parse_context(); |
| 28056 | int dumped = 0; |
| 28057 | |
| 28058 | cod_code gen_code; |
| 28059 | |
| 28060 | /* test for short - signed char */ |
| 28061 | if (verbose) printf("test for short - signed char"); |
| 28062 | |
| 28063 | cod_assoc_externs(context, externs); |
| 28064 | cod_parse_for_context(extern_string, context); |
| 28065 | |
| 28066 | cod_subroutine_declaration("short proc(short p1, signed char p2)", |
| 28067 | context); |
| 28068 | gen_code = cod_code_gen(code, context); |
| 28069 | proc = (short (*)(short, signed char))(long)gen_code->func; |
| 28070 | |
| 28071 | |
| 28072 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 28073 | short source1_s = src1s_vals[i]; |
| 28074 | for (j=0 ; j < sizeof(src2c_vals)/sizeof(src2c_vals[0]) ; j++) { |
| 28075 | signed char source2_c = src2c_vals[j]; |
| 28076 | |
| 28077 | short expected_result; |
| 28078 | short result; |
| 28079 | |
| 28080 | |
| 28081 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 28082 | |
| 28083 | expected_result = (short) (source1_s - source2_c); |
| 28084 | |
| 28085 | result = proc(source1_s, source2_c); |
| 28086 | if (expected_result != result) { |
| 28087 | printf("Failed short - signed char test, expected %d, got %d, for %d - %d\n", |
| 28088 | expected_result, result, source1_s, source2_c); |
| 28089 | if (dumped == 0) cod_dump(gen_code); |
| 28090 | failed++; |
| 28091 | dumped++; |
| 28092 | } |
| 28093 | } |
| 28094 | } |
| 28095 | if (verbose) printf(" done\n"); |
| 28096 | cod_free_parse_context(context); |
| 28097 | cod_code_free(gen_code); |
| 28098 | } |
| 28099 | if ((only_run_test == NULL((void*)0)) || |
| 28100 | (strcmp(only_run_test, "s-uc") == 0)) { |
| 28101 | int i, j; |
| 28102 | static char code[] = "{\n\ |
| 28103 | short a = p1;\n\ |
| 28104 | unsigned char b = p2;\n\ |
| 28105 | return a - b;\n\ |
| 28106 | }"; |
| 28107 | |
| 28108 | short (*proc)(short a, unsigned char b); |
| 28109 | cod_parse_context context = new_cod_parse_context(); |
| 28110 | int dumped = 0; |
| 28111 | |
| 28112 | cod_code gen_code; |
| 28113 | |
| 28114 | /* test for short - unsigned char */ |
| 28115 | if (verbose) printf("test for short - unsigned char"); |
| 28116 | |
| 28117 | cod_assoc_externs(context, externs); |
| 28118 | cod_parse_for_context(extern_string, context); |
| 28119 | |
| 28120 | cod_subroutine_declaration("short proc(short p1, unsigned char p2)", |
| 28121 | context); |
| 28122 | gen_code = cod_code_gen(code, context); |
| 28123 | proc = (short (*)(short, unsigned char))(long)gen_code->func; |
| 28124 | |
| 28125 | |
| 28126 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 28127 | short source1_s = src1s_vals[i]; |
| 28128 | for (j=0 ; j < sizeof(src2uc_vals)/sizeof(src2uc_vals[0]) ; j++) { |
| 28129 | unsigned char source2_uc = src2uc_vals[j]; |
| 28130 | |
| 28131 | short expected_result; |
| 28132 | short result; |
| 28133 | |
| 28134 | |
| 28135 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 28136 | |
| 28137 | expected_result = (short) (source1_s - source2_uc); |
| 28138 | |
| 28139 | result = proc(source1_s, source2_uc); |
| 28140 | if (expected_result != result) { |
| 28141 | printf("Failed short - unsigned char test, expected %d, got %d, for %d - %u\n", |
| 28142 | expected_result, result, source1_s, source2_uc); |
| 28143 | if (dumped == 0) cod_dump(gen_code); |
| 28144 | failed++; |
| 28145 | dumped++; |
| 28146 | } |
| 28147 | } |
| 28148 | } |
| 28149 | if (verbose) printf(" done\n"); |
| 28150 | cod_free_parse_context(context); |
| 28151 | cod_code_free(gen_code); |
| 28152 | } |
| 28153 | if ((only_run_test == NULL((void*)0)) || |
| 28154 | (strcmp(only_run_test, "s-s") == 0)) { |
| 28155 | int i, j; |
| 28156 | static char code[] = "{\n\ |
| 28157 | short a = p1;\n\ |
| 28158 | short b = p2;\n\ |
| 28159 | return a - b;\n\ |
| 28160 | }"; |
| 28161 | |
| 28162 | short (*proc)(short a, short b); |
| 28163 | cod_parse_context context = new_cod_parse_context(); |
| 28164 | int dumped = 0; |
| 28165 | |
| 28166 | cod_code gen_code; |
| 28167 | |
| 28168 | /* test for short - short */ |
| 28169 | if (verbose) printf("test for short - short"); |
| 28170 | |
| 28171 | cod_assoc_externs(context, externs); |
| 28172 | cod_parse_for_context(extern_string, context); |
| 28173 | |
| 28174 | cod_subroutine_declaration("short proc(short p1, short p2)", |
| 28175 | context); |
| 28176 | gen_code = cod_code_gen(code, context); |
| 28177 | proc = (short (*)(short, short))(long)gen_code->func; |
| 28178 | |
| 28179 | |
| 28180 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 28181 | short source1_s = src1s_vals[i]; |
| 28182 | for (j=0 ; j < sizeof(src2s_vals)/sizeof(src2s_vals[0]) ; j++) { |
| 28183 | short source2_s = src2s_vals[j]; |
| 28184 | |
| 28185 | short expected_result; |
| 28186 | short result; |
| 28187 | |
| 28188 | |
| 28189 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 28190 | |
| 28191 | expected_result = (short) (source1_s - source2_s); |
| 28192 | |
| 28193 | result = proc(source1_s, source2_s); |
| 28194 | if (expected_result != result) { |
| 28195 | printf("Failed short - short test, expected %d, got %d, for %d - %d\n", |
| 28196 | expected_result, result, source1_s, source2_s); |
| 28197 | if (dumped == 0) cod_dump(gen_code); |
| 28198 | failed++; |
| 28199 | dumped++; |
| 28200 | } |
| 28201 | } |
| 28202 | } |
| 28203 | if (verbose) printf(" done\n"); |
| 28204 | cod_free_parse_context(context); |
| 28205 | cod_code_free(gen_code); |
| 28206 | } |
| 28207 | if ((only_run_test == NULL((void*)0)) || |
| 28208 | (strcmp(only_run_test, "s-us") == 0)) { |
| 28209 | int i, j; |
| 28210 | static char code[] = "{\n\ |
| 28211 | short a = p1;\n\ |
| 28212 | unsigned short b = p2;\n\ |
| 28213 | return a - b;\n\ |
| 28214 | }"; |
| 28215 | |
| 28216 | short (*proc)(short a, unsigned short b); |
| 28217 | cod_parse_context context = new_cod_parse_context(); |
| 28218 | int dumped = 0; |
| 28219 | |
| 28220 | cod_code gen_code; |
| 28221 | |
| 28222 | /* test for short - unsigned short */ |
| 28223 | if (verbose) printf("test for short - unsigned short"); |
| 28224 | |
| 28225 | cod_assoc_externs(context, externs); |
| 28226 | cod_parse_for_context(extern_string, context); |
| 28227 | |
| 28228 | cod_subroutine_declaration("short proc(short p1, unsigned short p2)", |
| 28229 | context); |
| 28230 | gen_code = cod_code_gen(code, context); |
| 28231 | proc = (short (*)(short, unsigned short))(long)gen_code->func; |
| 28232 | |
| 28233 | |
| 28234 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 28235 | short source1_s = src1s_vals[i]; |
| 28236 | for (j=0 ; j < sizeof(src2us_vals)/sizeof(src2us_vals[0]) ; j++) { |
| 28237 | unsigned short source2_us = src2us_vals[j]; |
| 28238 | |
| 28239 | short expected_result; |
| 28240 | short result; |
| 28241 | |
| 28242 | |
| 28243 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 28244 | |
| 28245 | expected_result = (short) (source1_s - source2_us); |
| 28246 | |
| 28247 | result = proc(source1_s, source2_us); |
| 28248 | if (expected_result != result) { |
| 28249 | printf("Failed short - unsigned short test, expected %d, got %d, for %d - %u\n", |
| 28250 | expected_result, result, source1_s, source2_us); |
| 28251 | if (dumped == 0) cod_dump(gen_code); |
| 28252 | failed++; |
| 28253 | dumped++; |
| 28254 | } |
| 28255 | } |
| 28256 | } |
| 28257 | if (verbose) printf(" done\n"); |
| 28258 | cod_free_parse_context(context); |
| 28259 | cod_code_free(gen_code); |
| 28260 | } |
| 28261 | if ((only_run_test == NULL((void*)0)) || |
| 28262 | (strcmp(only_run_test, "s-i") == 0)) { |
| 28263 | int i, j; |
| 28264 | static char code[] = "{\n\ |
| 28265 | short a = p1;\n\ |
| 28266 | int b = p2;\n\ |
| 28267 | return a - b;\n\ |
| 28268 | }"; |
| 28269 | |
| 28270 | short (*proc)(short a, int b); |
| 28271 | cod_parse_context context = new_cod_parse_context(); |
| 28272 | int dumped = 0; |
| 28273 | |
| 28274 | cod_code gen_code; |
| 28275 | |
| 28276 | /* test for short - int */ |
| 28277 | if (verbose) printf("test for short - int"); |
| 28278 | |
| 28279 | cod_assoc_externs(context, externs); |
| 28280 | cod_parse_for_context(extern_string, context); |
| 28281 | |
| 28282 | cod_subroutine_declaration("short proc(short p1, int p2)", |
| 28283 | context); |
| 28284 | gen_code = cod_code_gen(code, context); |
| 28285 | proc = (short (*)(short, int))(long)gen_code->func; |
| 28286 | |
| 28287 | |
| 28288 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 28289 | short source1_s = src1s_vals[i]; |
| 28290 | for (j=0 ; j < sizeof(src2i_vals)/sizeof(src2i_vals[0]) ; j++) { |
| 28291 | int source2_i = src2i_vals[j]; |
| 28292 | |
| 28293 | short expected_result; |
| 28294 | short result; |
| 28295 | |
| 28296 | |
| 28297 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 28298 | |
| 28299 | expected_result = (short) (source1_s - source2_i); |
| 28300 | |
| 28301 | result = proc(source1_s, source2_i); |
| 28302 | if (expected_result != result) { |
| 28303 | printf("Failed short - int test, expected %d, got %d, for %d - %d\n", |
| 28304 | expected_result, result, source1_s, source2_i); |
| 28305 | if (dumped == 0) cod_dump(gen_code); |
| 28306 | failed++; |
| 28307 | dumped++; |
| 28308 | } |
| 28309 | } |
| 28310 | } |
| 28311 | if (verbose) printf(" done\n"); |
| 28312 | cod_free_parse_context(context); |
| 28313 | cod_code_free(gen_code); |
| 28314 | } |
| 28315 | if ((only_run_test == NULL((void*)0)) || |
| 28316 | (strcmp(only_run_test, "s-u") == 0)) { |
| 28317 | int i, j; |
| 28318 | static char code[] = "{\n\ |
| 28319 | short a = p1;\n\ |
| 28320 | unsigned int b = p2;\n\ |
| 28321 | return a - b;\n\ |
| 28322 | }"; |
| 28323 | |
| 28324 | short (*proc)(short a, unsigned int b); |
| 28325 | cod_parse_context context = new_cod_parse_context(); |
| 28326 | int dumped = 0; |
| 28327 | |
| 28328 | cod_code gen_code; |
| 28329 | |
| 28330 | /* test for short - unsigned int */ |
| 28331 | if (verbose) printf("test for short - unsigned int"); |
| 28332 | |
| 28333 | cod_assoc_externs(context, externs); |
| 28334 | cod_parse_for_context(extern_string, context); |
| 28335 | |
| 28336 | cod_subroutine_declaration("short proc(short p1, unsigned int p2)", |
| 28337 | context); |
| 28338 | gen_code = cod_code_gen(code, context); |
| 28339 | proc = (short (*)(short, unsigned int))(long)gen_code->func; |
| 28340 | |
| 28341 | |
| 28342 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 28343 | short source1_s = src1s_vals[i]; |
| 28344 | for (j=0 ; j < sizeof(src2u_vals)/sizeof(src2u_vals[0]) ; j++) { |
| 28345 | unsigned int source2_u = src2u_vals[j]; |
| 28346 | |
| 28347 | short expected_result; |
| 28348 | short result; |
| 28349 | |
| 28350 | |
| 28351 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 28352 | |
| 28353 | expected_result = (short) (source1_s - source2_u); |
| 28354 | |
| 28355 | result = proc(source1_s, source2_u); |
| 28356 | if (expected_result != result) { |
| 28357 | printf("Failed short - unsigned int test, expected %d, got %d, for %d - %u\n", |
| 28358 | expected_result, result, source1_s, source2_u); |
| 28359 | if (dumped == 0) cod_dump(gen_code); |
| 28360 | failed++; |
| 28361 | dumped++; |
| 28362 | } |
| 28363 | } |
| 28364 | } |
| 28365 | if (verbose) printf(" done\n"); |
| 28366 | cod_free_parse_context(context); |
| 28367 | cod_code_free(gen_code); |
| 28368 | } |
| 28369 | if ((only_run_test == NULL((void*)0)) || |
| 28370 | (strcmp(only_run_test, "s-ul") == 0)) { |
| 28371 | int i, j; |
| 28372 | static char code[] = "{\n\ |
| 28373 | short a = p1;\n\ |
| 28374 | unsigned long b = p2;\n\ |
| 28375 | return a - b;\n\ |
| 28376 | }"; |
| 28377 | |
| 28378 | short (*proc)(short a, unsigned long b); |
| 28379 | cod_parse_context context = new_cod_parse_context(); |
| 28380 | int dumped = 0; |
| 28381 | |
| 28382 | cod_code gen_code; |
| 28383 | |
| 28384 | /* test for short - unsigned long */ |
| 28385 | if (verbose) printf("test for short - unsigned long"); |
| 28386 | |
| 28387 | cod_assoc_externs(context, externs); |
| 28388 | cod_parse_for_context(extern_string, context); |
| 28389 | |
| 28390 | cod_subroutine_declaration("short proc(short p1, unsigned long p2)", |
| 28391 | context); |
| 28392 | gen_code = cod_code_gen(code, context); |
| 28393 | proc = (short (*)(short, unsigned long))(long)gen_code->func; |
| 28394 | |
| 28395 | |
| 28396 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 28397 | short source1_s = src1s_vals[i]; |
| 28398 | for (j=0 ; j < sizeof(src2ul_vals)/sizeof(src2ul_vals[0]) ; j++) { |
| 28399 | unsigned long source2_ul = src2ul_vals[j]; |
| 28400 | |
| 28401 | short expected_result; |
| 28402 | short result; |
| 28403 | |
| 28404 | |
| 28405 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 28406 | |
| 28407 | expected_result = (short) (source1_s - source2_ul); |
| 28408 | |
| 28409 | result = proc(source1_s, source2_ul); |
| 28410 | if (expected_result != result) { |
| 28411 | printf("Failed short - unsigned long test, expected %d, got %d, for %d - %lu\n", |
| 28412 | expected_result, result, source1_s, source2_ul); |
| 28413 | if (dumped == 0) cod_dump(gen_code); |
| 28414 | failed++; |
| 28415 | dumped++; |
| 28416 | } |
| 28417 | } |
| 28418 | } |
| 28419 | if (verbose) printf(" done\n"); |
| 28420 | cod_free_parse_context(context); |
| 28421 | cod_code_free(gen_code); |
| 28422 | } |
| 28423 | if ((only_run_test == NULL((void*)0)) || |
| 28424 | (strcmp(only_run_test, "s-l") == 0)) { |
| 28425 | int i, j; |
| 28426 | static char code[] = "{\n\ |
| 28427 | short a = p1;\n\ |
| 28428 | long b = p2;\n\ |
| 28429 | return a - b;\n\ |
| 28430 | }"; |
| 28431 | |
| 28432 | short (*proc)(short a, long b); |
| 28433 | cod_parse_context context = new_cod_parse_context(); |
| 28434 | int dumped = 0; |
| 28435 | |
| 28436 | cod_code gen_code; |
| 28437 | |
| 28438 | /* test for short - long */ |
| 28439 | if (verbose) printf("test for short - long"); |
| 28440 | |
| 28441 | cod_assoc_externs(context, externs); |
| 28442 | cod_parse_for_context(extern_string, context); |
| 28443 | |
| 28444 | cod_subroutine_declaration("short proc(short p1, long p2)", |
| 28445 | context); |
| 28446 | gen_code = cod_code_gen(code, context); |
| 28447 | proc = (short (*)(short, long))(long)gen_code->func; |
| 28448 | |
| 28449 | |
| 28450 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 28451 | short source1_s = src1s_vals[i]; |
| 28452 | for (j=0 ; j < sizeof(src2l_vals)/sizeof(src2l_vals[0]) ; j++) { |
| 28453 | long source2_l = src2l_vals[j]; |
| 28454 | |
| 28455 | short expected_result; |
| 28456 | short result; |
| 28457 | |
| 28458 | |
| 28459 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 28460 | |
| 28461 | expected_result = (short) (source1_s - source2_l); |
| 28462 | |
| 28463 | result = proc(source1_s, source2_l); |
| 28464 | if (expected_result != result) { |
| 28465 | printf("Failed short - long test, expected %d, got %d, for %d - %ld\n", |
| 28466 | expected_result, result, source1_s, source2_l); |
| 28467 | if (dumped == 0) cod_dump(gen_code); |
| 28468 | failed++; |
| 28469 | dumped++; |
| 28470 | } |
| 28471 | } |
| 28472 | } |
| 28473 | if (verbose) printf(" done\n"); |
| 28474 | cod_free_parse_context(context); |
| 28475 | cod_code_free(gen_code); |
| 28476 | } |
| 28477 | if ((only_run_test == NULL((void*)0)) || |
| 28478 | (strcmp(only_run_test, "s-f") == 0)) { |
| 28479 | int i, j; |
| 28480 | static char code[] = "{\n\ |
| 28481 | short a = p1;\n\ |
| 28482 | float b = p2;\n\ |
| 28483 | return a - b;\n\ |
| 28484 | }"; |
| 28485 | |
| 28486 | short (*proc)(short a, float b); |
| 28487 | cod_parse_context context = new_cod_parse_context(); |
| 28488 | int dumped = 0; |
| 28489 | |
| 28490 | cod_code gen_code; |
| 28491 | |
| 28492 | /* test for short - float */ |
| 28493 | if (verbose) printf("test for short - float"); |
| 28494 | |
| 28495 | cod_assoc_externs(context, externs); |
| 28496 | cod_parse_for_context(extern_string, context); |
| 28497 | |
| 28498 | cod_subroutine_declaration("short proc(short p1, float p2)", |
| 28499 | context); |
| 28500 | gen_code = cod_code_gen(code, context); |
| 28501 | proc = (short (*)(short, float))(long)gen_code->func; |
| 28502 | |
| 28503 | |
| 28504 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 28505 | short source1_s = src1s_vals[i]; |
| 28506 | for (j=0 ; j < sizeof(src2f_vals)/sizeof(src2f_vals[0]) ; j++) { |
| 28507 | float source2_f = src2f_vals[j]; |
| 28508 | double range = 0.000001 * (fabs((double)source1_s) + fabs((double)source2_f)); |
| 28509 | short expected_result; |
| 28510 | short result; |
| 28511 | |
| 28512 | |
| 28513 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 28514 | |
| 28515 | expected_result = (short) (source1_s - source2_f); |
| 28516 | |
| 28517 | result = proc(source1_s, source2_f); |
| 28518 | range += 1.0; |
| 28519 | if ((result > (expected_result + range)) || (result < (expected_result - range))) { |
| 28520 | printf("Failed short - float test, expected %d, got %d, for %d - %g\n", |
| 28521 | expected_result, result, source1_s, source2_f); |
| 28522 | if (dumped == 0) cod_dump(gen_code); |
| 28523 | failed++; |
| 28524 | dumped++; |
| 28525 | } |
| 28526 | } |
| 28527 | } |
| 28528 | if (verbose) printf(" done\n"); |
| 28529 | cod_free_parse_context(context); |
| 28530 | cod_code_free(gen_code); |
| 28531 | } |
| 28532 | if ((only_run_test == NULL((void*)0)) || |
| 28533 | (strcmp(only_run_test, "s-d") == 0)) { |
| 28534 | int i, j; |
| 28535 | static char code[] = "{\n\ |
| 28536 | short a = p1;\n\ |
| 28537 | double b = p2;\n\ |
| 28538 | return a - b;\n\ |
| 28539 | }"; |
| 28540 | |
| 28541 | short (*proc)(short a, double b); |
| 28542 | cod_parse_context context = new_cod_parse_context(); |
| 28543 | int dumped = 0; |
| 28544 | |
| 28545 | cod_code gen_code; |
| 28546 | |
| 28547 | /* test for short - double */ |
| 28548 | if (verbose) printf("test for short - double"); |
| 28549 | |
| 28550 | cod_assoc_externs(context, externs); |
| 28551 | cod_parse_for_context(extern_string, context); |
| 28552 | |
| 28553 | cod_subroutine_declaration("short proc(short p1, double p2)", |
| 28554 | context); |
| 28555 | gen_code = cod_code_gen(code, context); |
| 28556 | proc = (short (*)(short, double))(long)gen_code->func; |
| 28557 | |
| 28558 | |
| 28559 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 28560 | short source1_s = src1s_vals[i]; |
| 28561 | for (j=0 ; j < sizeof(src2d_vals)/sizeof(src2d_vals[0]) ; j++) { |
| 28562 | double source2_d = src2d_vals[j]; |
| 28563 | |
| 28564 | short expected_result; |
| 28565 | short result; |
| 28566 | |
| 28567 | |
| 28568 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 28569 | |
| 28570 | expected_result = (short) (source1_s - source2_d); |
| 28571 | |
| 28572 | result = proc(source1_s, source2_d); |
| 28573 | if (expected_result != result) { |
| 28574 | printf("Failed short - double test, expected %d, got %d, for %d - %g\n", |
| 28575 | expected_result, result, source1_s, source2_d); |
| 28576 | if (dumped == 0) cod_dump(gen_code); |
| 28577 | failed++; |
| 28578 | dumped++; |
| 28579 | } |
| 28580 | } |
| 28581 | } |
| 28582 | if (verbose) printf(" done\n"); |
| 28583 | cod_free_parse_context(context); |
| 28584 | cod_code_free(gen_code); |
| 28585 | } |
| 28586 | } |
| 28587 | void sub_us_tests() |
| 28588 | { |
| 28589 | if ((only_run_test == NULL((void*)0)) || |
| 28590 | (strcmp(only_run_test, "us-c") == 0)) { |
| 28591 | int i, j; |
| 28592 | static char code[] = "{\n\ |
| 28593 | unsigned short a = p1;\n\ |
| 28594 | signed char b = p2;\n\ |
| 28595 | return a - b;\n\ |
| 28596 | }"; |
| 28597 | |
| 28598 | unsigned short (*proc)(unsigned short a, signed char b); |
| 28599 | cod_parse_context context = new_cod_parse_context(); |
| 28600 | int dumped = 0; |
| 28601 | |
| 28602 | cod_code gen_code; |
| 28603 | |
| 28604 | /* test for unsigned short - signed char */ |
| 28605 | if (verbose) printf("test for unsigned short - signed char"); |
| 28606 | |
| 28607 | cod_assoc_externs(context, externs); |
| 28608 | cod_parse_for_context(extern_string, context); |
| 28609 | |
| 28610 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, signed char p2)", |
| 28611 | context); |
| 28612 | gen_code = cod_code_gen(code, context); |
| 28613 | proc = (unsigned short (*)(unsigned short, signed char))(long)gen_code->func; |
| 28614 | |
| 28615 | |
| 28616 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 28617 | unsigned short source1_us = src1us_vals[i]; |
| 28618 | for (j=0 ; j < sizeof(src2c_vals)/sizeof(src2c_vals[0]) ; j++) { |
| 28619 | signed char source2_c = src2c_vals[j]; |
| 28620 | |
| 28621 | unsigned short expected_result; |
| 28622 | unsigned short result; |
| 28623 | |
| 28624 | |
| 28625 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 28626 | |
| 28627 | expected_result = (unsigned short) (source1_us - source2_c); |
| 28628 | |
| 28629 | result = proc(source1_us, source2_c); |
| 28630 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 28631 | if (expected_result != result) { |
| 28632 | printf("Failed unsigned short - signed char test, expected %u, got %u, for %u - %d\n", |
| 28633 | expected_result, result, source1_us, source2_c); |
| 28634 | if (dumped == 0) cod_dump(gen_code); |
| 28635 | failed++; |
| 28636 | dumped++; |
| 28637 | } |
| 28638 | } |
| 28639 | } |
| 28640 | if (verbose) printf(" done\n"); |
| 28641 | cod_free_parse_context(context); |
| 28642 | cod_code_free(gen_code); |
| 28643 | } |
| 28644 | if ((only_run_test == NULL((void*)0)) || |
| 28645 | (strcmp(only_run_test, "us-uc") == 0)) { |
| 28646 | int i, j; |
| 28647 | static char code[] = "{\n\ |
| 28648 | unsigned short a = p1;\n\ |
| 28649 | unsigned char b = p2;\n\ |
| 28650 | return a - b;\n\ |
| 28651 | }"; |
| 28652 | |
| 28653 | unsigned short (*proc)(unsigned short a, unsigned char b); |
| 28654 | cod_parse_context context = new_cod_parse_context(); |
| 28655 | int dumped = 0; |
| 28656 | |
| 28657 | cod_code gen_code; |
| 28658 | |
| 28659 | /* test for unsigned short - unsigned char */ |
| 28660 | if (verbose) printf("test for unsigned short - unsigned char"); |
| 28661 | |
| 28662 | cod_assoc_externs(context, externs); |
| 28663 | cod_parse_for_context(extern_string, context); |
| 28664 | |
| 28665 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, unsigned char p2)", |
| 28666 | context); |
| 28667 | gen_code = cod_code_gen(code, context); |
| 28668 | proc = (unsigned short (*)(unsigned short, unsigned char))(long)gen_code->func; |
| 28669 | |
| 28670 | |
| 28671 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 28672 | unsigned short source1_us = src1us_vals[i]; |
| 28673 | for (j=0 ; j < sizeof(src2uc_vals)/sizeof(src2uc_vals[0]) ; j++) { |
| 28674 | unsigned char source2_uc = src2uc_vals[j]; |
| 28675 | |
| 28676 | unsigned short expected_result; |
| 28677 | unsigned short result; |
| 28678 | |
| 28679 | |
| 28680 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 28681 | |
| 28682 | expected_result = (unsigned short) (source1_us - source2_uc); |
| 28683 | |
| 28684 | result = proc(source1_us, source2_uc); |
| 28685 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 28686 | if (expected_result != result) { |
| 28687 | printf("Failed unsigned short - unsigned char test, expected %u, got %u, for %u - %u\n", |
| 28688 | expected_result, result, source1_us, source2_uc); |
| 28689 | if (dumped == 0) cod_dump(gen_code); |
| 28690 | failed++; |
| 28691 | dumped++; |
| 28692 | } |
| 28693 | } |
| 28694 | } |
| 28695 | if (verbose) printf(" done\n"); |
| 28696 | cod_free_parse_context(context); |
| 28697 | cod_code_free(gen_code); |
| 28698 | } |
| 28699 | if ((only_run_test == NULL((void*)0)) || |
| 28700 | (strcmp(only_run_test, "us-s") == 0)) { |
| 28701 | int i, j; |
| 28702 | static char code[] = "{\n\ |
| 28703 | unsigned short a = p1;\n\ |
| 28704 | short b = p2;\n\ |
| 28705 | return a - b;\n\ |
| 28706 | }"; |
| 28707 | |
| 28708 | unsigned short (*proc)(unsigned short a, short b); |
| 28709 | cod_parse_context context = new_cod_parse_context(); |
| 28710 | int dumped = 0; |
| 28711 | |
| 28712 | cod_code gen_code; |
| 28713 | |
| 28714 | /* test for unsigned short - short */ |
| 28715 | if (verbose) printf("test for unsigned short - short"); |
| 28716 | |
| 28717 | cod_assoc_externs(context, externs); |
| 28718 | cod_parse_for_context(extern_string, context); |
| 28719 | |
| 28720 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, short p2)", |
| 28721 | context); |
| 28722 | gen_code = cod_code_gen(code, context); |
| 28723 | proc = (unsigned short (*)(unsigned short, short))(long)gen_code->func; |
| 28724 | |
| 28725 | |
| 28726 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 28727 | unsigned short source1_us = src1us_vals[i]; |
| 28728 | for (j=0 ; j < sizeof(src2s_vals)/sizeof(src2s_vals[0]) ; j++) { |
| 28729 | short source2_s = src2s_vals[j]; |
| 28730 | |
| 28731 | unsigned short expected_result; |
| 28732 | unsigned short result; |
| 28733 | |
| 28734 | |
| 28735 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 28736 | |
| 28737 | expected_result = (unsigned short) (source1_us - source2_s); |
| 28738 | |
| 28739 | result = proc(source1_us, source2_s); |
| 28740 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 28741 | if (expected_result != result) { |
| 28742 | printf("Failed unsigned short - short test, expected %u, got %u, for %u - %d\n", |
| 28743 | expected_result, result, source1_us, source2_s); |
| 28744 | if (dumped == 0) cod_dump(gen_code); |
| 28745 | failed++; |
| 28746 | dumped++; |
| 28747 | } |
| 28748 | } |
| 28749 | } |
| 28750 | if (verbose) printf(" done\n"); |
| 28751 | cod_free_parse_context(context); |
| 28752 | cod_code_free(gen_code); |
| 28753 | } |
| 28754 | if ((only_run_test == NULL((void*)0)) || |
| 28755 | (strcmp(only_run_test, "us-us") == 0)) { |
| 28756 | int i, j; |
| 28757 | static char code[] = "{\n\ |
| 28758 | unsigned short a = p1;\n\ |
| 28759 | unsigned short b = p2;\n\ |
| 28760 | return a - b;\n\ |
| 28761 | }"; |
| 28762 | |
| 28763 | unsigned short (*proc)(unsigned short a, unsigned short b); |
| 28764 | cod_parse_context context = new_cod_parse_context(); |
| 28765 | int dumped = 0; |
| 28766 | |
| 28767 | cod_code gen_code; |
| 28768 | |
| 28769 | /* test for unsigned short - unsigned short */ |
| 28770 | if (verbose) printf("test for unsigned short - unsigned short"); |
| 28771 | |
| 28772 | cod_assoc_externs(context, externs); |
| 28773 | cod_parse_for_context(extern_string, context); |
| 28774 | |
| 28775 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, unsigned short p2)", |
| 28776 | context); |
| 28777 | gen_code = cod_code_gen(code, context); |
| 28778 | proc = (unsigned short (*)(unsigned short, unsigned short))(long)gen_code->func; |
| 28779 | |
| 28780 | |
| 28781 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 28782 | unsigned short source1_us = src1us_vals[i]; |
| 28783 | for (j=0 ; j < sizeof(src2us_vals)/sizeof(src2us_vals[0]) ; j++) { |
| 28784 | unsigned short source2_us = src2us_vals[j]; |
| 28785 | |
| 28786 | unsigned short expected_result; |
| 28787 | unsigned short result; |
| 28788 | |
| 28789 | |
| 28790 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 28791 | |
| 28792 | expected_result = (unsigned short) (source1_us - source2_us); |
| 28793 | |
| 28794 | result = proc(source1_us, source2_us); |
| 28795 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 28796 | if (expected_result != result) { |
| 28797 | printf("Failed unsigned short - unsigned short test, expected %u, got %u, for %u - %u\n", |
| 28798 | expected_result, result, source1_us, source2_us); |
| 28799 | if (dumped == 0) cod_dump(gen_code); |
| 28800 | failed++; |
| 28801 | dumped++; |
| 28802 | } |
| 28803 | } |
| 28804 | } |
| 28805 | if (verbose) printf(" done\n"); |
| 28806 | cod_free_parse_context(context); |
| 28807 | cod_code_free(gen_code); |
| 28808 | } |
| 28809 | if ((only_run_test == NULL((void*)0)) || |
| 28810 | (strcmp(only_run_test, "us-i") == 0)) { |
| 28811 | int i, j; |
| 28812 | static char code[] = "{\n\ |
| 28813 | unsigned short a = p1;\n\ |
| 28814 | int b = p2;\n\ |
| 28815 | return a - b;\n\ |
| 28816 | }"; |
| 28817 | |
| 28818 | unsigned short (*proc)(unsigned short a, int b); |
| 28819 | cod_parse_context context = new_cod_parse_context(); |
| 28820 | int dumped = 0; |
| 28821 | |
| 28822 | cod_code gen_code; |
| 28823 | |
| 28824 | /* test for unsigned short - int */ |
| 28825 | if (verbose) printf("test for unsigned short - int"); |
| 28826 | |
| 28827 | cod_assoc_externs(context, externs); |
| 28828 | cod_parse_for_context(extern_string, context); |
| 28829 | |
| 28830 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, int p2)", |
| 28831 | context); |
| 28832 | gen_code = cod_code_gen(code, context); |
| 28833 | proc = (unsigned short (*)(unsigned short, int))(long)gen_code->func; |
| 28834 | |
| 28835 | |
| 28836 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 28837 | unsigned short source1_us = src1us_vals[i]; |
| 28838 | for (j=0 ; j < sizeof(src2i_vals)/sizeof(src2i_vals[0]) ; j++) { |
| 28839 | int source2_i = src2i_vals[j]; |
| 28840 | |
| 28841 | unsigned short expected_result; |
| 28842 | unsigned short result; |
| 28843 | |
| 28844 | |
| 28845 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 28846 | |
| 28847 | expected_result = (unsigned short) (source1_us - source2_i); |
| 28848 | |
| 28849 | result = proc(source1_us, source2_i); |
| 28850 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 28851 | if (expected_result != result) { |
| 28852 | printf("Failed unsigned short - int test, expected %u, got %u, for %u - %d\n", |
| 28853 | expected_result, result, source1_us, source2_i); |
| 28854 | if (dumped == 0) cod_dump(gen_code); |
| 28855 | failed++; |
| 28856 | dumped++; |
| 28857 | } |
| 28858 | } |
| 28859 | } |
| 28860 | if (verbose) printf(" done\n"); |
| 28861 | cod_free_parse_context(context); |
| 28862 | cod_code_free(gen_code); |
| 28863 | } |
| 28864 | if ((only_run_test == NULL((void*)0)) || |
| 28865 | (strcmp(only_run_test, "us-u") == 0)) { |
| 28866 | int i, j; |
| 28867 | static char code[] = "{\n\ |
| 28868 | unsigned short a = p1;\n\ |
| 28869 | unsigned int b = p2;\n\ |
| 28870 | return a - b;\n\ |
| 28871 | }"; |
| 28872 | |
| 28873 | unsigned short (*proc)(unsigned short a, unsigned int b); |
| 28874 | cod_parse_context context = new_cod_parse_context(); |
| 28875 | int dumped = 0; |
| 28876 | |
| 28877 | cod_code gen_code; |
| 28878 | |
| 28879 | /* test for unsigned short - unsigned int */ |
| 28880 | if (verbose) printf("test for unsigned short - unsigned int"); |
| 28881 | |
| 28882 | cod_assoc_externs(context, externs); |
| 28883 | cod_parse_for_context(extern_string, context); |
| 28884 | |
| 28885 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, unsigned int p2)", |
| 28886 | context); |
| 28887 | gen_code = cod_code_gen(code, context); |
| 28888 | proc = (unsigned short (*)(unsigned short, unsigned int))(long)gen_code->func; |
| 28889 | |
| 28890 | |
| 28891 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 28892 | unsigned short source1_us = src1us_vals[i]; |
| 28893 | for (j=0 ; j < sizeof(src2u_vals)/sizeof(src2u_vals[0]) ; j++) { |
| 28894 | unsigned int source2_u = src2u_vals[j]; |
| 28895 | |
| 28896 | unsigned short expected_result; |
| 28897 | unsigned short result; |
| 28898 | |
| 28899 | |
| 28900 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 28901 | |
| 28902 | expected_result = (unsigned short) (source1_us - source2_u); |
| 28903 | |
| 28904 | result = proc(source1_us, source2_u); |
| 28905 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 28906 | if (expected_result != result) { |
| 28907 | printf("Failed unsigned short - unsigned int test, expected %u, got %u, for %u - %u\n", |
| 28908 | expected_result, result, source1_us, source2_u); |
| 28909 | if (dumped == 0) cod_dump(gen_code); |
| 28910 | failed++; |
| 28911 | dumped++; |
| 28912 | } |
| 28913 | } |
| 28914 | } |
| 28915 | if (verbose) printf(" done\n"); |
| 28916 | cod_free_parse_context(context); |
| 28917 | cod_code_free(gen_code); |
| 28918 | } |
| 28919 | if ((only_run_test == NULL((void*)0)) || |
| 28920 | (strcmp(only_run_test, "us-ul") == 0)) { |
| 28921 | int i, j; |
| 28922 | static char code[] = "{\n\ |
| 28923 | unsigned short a = p1;\n\ |
| 28924 | unsigned long b = p2;\n\ |
| 28925 | return a - b;\n\ |
| 28926 | }"; |
| 28927 | |
| 28928 | unsigned short (*proc)(unsigned short a, unsigned long b); |
| 28929 | cod_parse_context context = new_cod_parse_context(); |
| 28930 | int dumped = 0; |
| 28931 | |
| 28932 | cod_code gen_code; |
| 28933 | |
| 28934 | /* test for unsigned short - unsigned long */ |
| 28935 | if (verbose) printf("test for unsigned short - unsigned long"); |
| 28936 | |
| 28937 | cod_assoc_externs(context, externs); |
| 28938 | cod_parse_for_context(extern_string, context); |
| 28939 | |
| 28940 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, unsigned long p2)", |
| 28941 | context); |
| 28942 | gen_code = cod_code_gen(code, context); |
| 28943 | proc = (unsigned short (*)(unsigned short, unsigned long))(long)gen_code->func; |
| 28944 | |
| 28945 | |
| 28946 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 28947 | unsigned short source1_us = src1us_vals[i]; |
| 28948 | for (j=0 ; j < sizeof(src2ul_vals)/sizeof(src2ul_vals[0]) ; j++) { |
| 28949 | unsigned long source2_ul = src2ul_vals[j]; |
| 28950 | |
| 28951 | unsigned short expected_result; |
| 28952 | unsigned short result; |
| 28953 | |
| 28954 | |
| 28955 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 28956 | |
| 28957 | expected_result = (unsigned short) (source1_us - source2_ul); |
| 28958 | |
| 28959 | result = proc(source1_us, source2_ul); |
| 28960 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 28961 | if (expected_result != result) { |
| 28962 | printf("Failed unsigned short - unsigned long test, expected %u, got %u, for %u - %lu\n", |
| 28963 | expected_result, result, source1_us, source2_ul); |
| 28964 | if (dumped == 0) cod_dump(gen_code); |
| 28965 | failed++; |
| 28966 | dumped++; |
| 28967 | } |
| 28968 | } |
| 28969 | } |
| 28970 | if (verbose) printf(" done\n"); |
| 28971 | cod_free_parse_context(context); |
| 28972 | cod_code_free(gen_code); |
| 28973 | } |
| 28974 | if ((only_run_test == NULL((void*)0)) || |
| 28975 | (strcmp(only_run_test, "us-l") == 0)) { |
| 28976 | int i, j; |
| 28977 | static char code[] = "{\n\ |
| 28978 | unsigned short a = p1;\n\ |
| 28979 | long b = p2;\n\ |
| 28980 | return a - b;\n\ |
| 28981 | }"; |
| 28982 | |
| 28983 | unsigned short (*proc)(unsigned short a, long b); |
| 28984 | cod_parse_context context = new_cod_parse_context(); |
| 28985 | int dumped = 0; |
| 28986 | |
| 28987 | cod_code gen_code; |
| 28988 | |
| 28989 | /* test for unsigned short - long */ |
| 28990 | if (verbose) printf("test for unsigned short - long"); |
| 28991 | |
| 28992 | cod_assoc_externs(context, externs); |
| 28993 | cod_parse_for_context(extern_string, context); |
| 28994 | |
| 28995 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, long p2)", |
| 28996 | context); |
| 28997 | gen_code = cod_code_gen(code, context); |
| 28998 | proc = (unsigned short (*)(unsigned short, long))(long)gen_code->func; |
| 28999 | |
| 29000 | |
| 29001 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 29002 | unsigned short source1_us = src1us_vals[i]; |
| 29003 | for (j=0 ; j < sizeof(src2l_vals)/sizeof(src2l_vals[0]) ; j++) { |
| 29004 | long source2_l = src2l_vals[j]; |
| 29005 | |
| 29006 | unsigned short expected_result; |
| 29007 | unsigned short result; |
| 29008 | |
| 29009 | |
| 29010 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 29011 | |
| 29012 | expected_result = (unsigned short) (source1_us - source2_l); |
| 29013 | |
| 29014 | result = proc(source1_us, source2_l); |
| 29015 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 29016 | if (expected_result != result) { |
| 29017 | printf("Failed unsigned short - long test, expected %u, got %u, for %u - %ld\n", |
| 29018 | expected_result, result, source1_us, source2_l); |
| 29019 | if (dumped == 0) cod_dump(gen_code); |
| 29020 | failed++; |
| 29021 | dumped++; |
| 29022 | } |
| 29023 | } |
| 29024 | } |
| 29025 | if (verbose) printf(" done\n"); |
| 29026 | cod_free_parse_context(context); |
| 29027 | cod_code_free(gen_code); |
| 29028 | } |
| 29029 | if ((only_run_test == NULL((void*)0)) || |
| 29030 | (strcmp(only_run_test, "us-f") == 0)) { |
| 29031 | int i, j; |
| 29032 | static char code[] = "{\n\ |
| 29033 | unsigned short a = p1;\n\ |
| 29034 | float b = p2;\n\ |
| 29035 | return a - b;\n\ |
| 29036 | }"; |
| 29037 | |
| 29038 | unsigned short (*proc)(unsigned short a, float b); |
| 29039 | cod_parse_context context = new_cod_parse_context(); |
| 29040 | int dumped = 0; |
| 29041 | |
| 29042 | cod_code gen_code; |
| 29043 | |
| 29044 | /* test for unsigned short - float */ |
| 29045 | if (verbose) printf("test for unsigned short - float"); |
| 29046 | |
| 29047 | cod_assoc_externs(context, externs); |
| 29048 | cod_parse_for_context(extern_string, context); |
| 29049 | |
| 29050 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, float p2)", |
| 29051 | context); |
| 29052 | gen_code = cod_code_gen(code, context); |
| 29053 | proc = (unsigned short (*)(unsigned short, float))(long)gen_code->func; |
| 29054 | |
| 29055 | |
| 29056 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 29057 | unsigned short source1_us = src1us_vals[i]; |
| 29058 | for (j=0 ; j < sizeof(src2f_vals)/sizeof(src2f_vals[0]) ; j++) { |
| 29059 | float source2_f = src2f_vals[j]; |
| 29060 | double range = 0.000001 * (fabs((double)source1_us) + fabs((double)source2_f)); |
| 29061 | unsigned short expected_result; |
| 29062 | unsigned short result; |
| 29063 | |
| 29064 | |
| 29065 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 29066 | |
| 29067 | expected_result = (unsigned short) (source1_us - source2_f); |
| 29068 | |
| 29069 | result = proc(source1_us, source2_f); |
| 29070 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 29071 | range += 1.0; |
| 29072 | if ((result > (expected_result + range)) || (result < (expected_result - range))) { |
| 29073 | printf("Failed unsigned short - float test, expected %u, got %u, for %u - %g\n", |
| 29074 | expected_result, result, source1_us, source2_f); |
| 29075 | if (dumped == 0) cod_dump(gen_code); |
| 29076 | failed++; |
| 29077 | dumped++; |
| 29078 | } |
| 29079 | } |
| 29080 | } |
| 29081 | if (verbose) printf(" done\n"); |
| 29082 | cod_free_parse_context(context); |
| 29083 | cod_code_free(gen_code); |
| 29084 | } |
| 29085 | if ((only_run_test == NULL((void*)0)) || |
| 29086 | (strcmp(only_run_test, "us-d") == 0)) { |
| 29087 | int i, j; |
| 29088 | static char code[] = "{\n\ |
| 29089 | unsigned short a = p1;\n\ |
| 29090 | double b = p2;\n\ |
| 29091 | return a - b;\n\ |
| 29092 | }"; |
| 29093 | |
| 29094 | unsigned short (*proc)(unsigned short a, double b); |
| 29095 | cod_parse_context context = new_cod_parse_context(); |
| 29096 | int dumped = 0; |
| 29097 | |
| 29098 | cod_code gen_code; |
| 29099 | |
| 29100 | /* test for unsigned short - double */ |
| 29101 | if (verbose) printf("test for unsigned short - double"); |
| 29102 | |
| 29103 | cod_assoc_externs(context, externs); |
| 29104 | cod_parse_for_context(extern_string, context); |
| 29105 | |
| 29106 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, double p2)", |
| 29107 | context); |
| 29108 | gen_code = cod_code_gen(code, context); |
| 29109 | proc = (unsigned short (*)(unsigned short, double))(long)gen_code->func; |
| 29110 | |
| 29111 | |
| 29112 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 29113 | unsigned short source1_us = src1us_vals[i]; |
| 29114 | for (j=0 ; j < sizeof(src2d_vals)/sizeof(src2d_vals[0]) ; j++) { |
| 29115 | double source2_d = src2d_vals[j]; |
| 29116 | |
| 29117 | unsigned short expected_result; |
| 29118 | unsigned short result; |
| 29119 | |
| 29120 | |
| 29121 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 29122 | |
| 29123 | expected_result = (unsigned short) (source1_us - source2_d); |
| 29124 | |
| 29125 | result = proc(source1_us, source2_d); |
| 29126 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 29127 | if (expected_result != result) { |
| 29128 | printf("Failed unsigned short - double test, expected %u, got %u, for %u - %g\n", |
| 29129 | expected_result, result, source1_us, source2_d); |
| 29130 | if (dumped == 0) cod_dump(gen_code); |
| 29131 | failed++; |
| 29132 | dumped++; |
| 29133 | } |
| 29134 | } |
| 29135 | } |
| 29136 | if (verbose) printf(" done\n"); |
| 29137 | cod_free_parse_context(context); |
| 29138 | cod_code_free(gen_code); |
| 29139 | } |
| 29140 | } |
| 29141 | void sub_i_tests() |
| 29142 | { |
| 29143 | if ((only_run_test == NULL((void*)0)) || |
| 29144 | (strcmp(only_run_test, "i-c") == 0)) { |
| 29145 | int i, j; |
| 29146 | static char code[] = "{\n\ |
| 29147 | int a = p1;\n\ |
| 29148 | signed char b = p2;\n\ |
| 29149 | return a - b;\n\ |
| 29150 | }"; |
| 29151 | |
| 29152 | int (*proc)(int a, signed char b); |
| 29153 | cod_parse_context context = new_cod_parse_context(); |
| 29154 | int dumped = 0; |
| 29155 | |
| 29156 | cod_code gen_code; |
| 29157 | |
| 29158 | /* test for int - signed char */ |
| 29159 | if (verbose) printf("test for int - signed char"); |
| 29160 | |
| 29161 | cod_assoc_externs(context, externs); |
| 29162 | cod_parse_for_context(extern_string, context); |
| 29163 | |
| 29164 | cod_subroutine_declaration("int proc(int p1, signed char p2)", |
| 29165 | context); |
| 29166 | gen_code = cod_code_gen(code, context); |
| 29167 | proc = (int (*)(int, signed char))(long)gen_code->func; |
| 29168 | |
| 29169 | |
| 29170 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 29171 | int source1_i = src1i_vals[i]; |
| 29172 | for (j=0 ; j < sizeof(src2c_vals)/sizeof(src2c_vals[0]) ; j++) { |
| 29173 | signed char source2_c = src2c_vals[j]; |
| 29174 | |
| 29175 | int expected_result; |
| 29176 | int result; |
| 29177 | |
| 29178 | |
| 29179 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 29180 | |
| 29181 | expected_result = (int) (source1_i - source2_c); |
| 29182 | |
| 29183 | result = proc(source1_i, source2_c); |
| 29184 | if (expected_result != result) { |
| 29185 | printf("Failed int - signed char test, expected %d, got %d, for %d - %d\n", |
| 29186 | expected_result, result, source1_i, source2_c); |
| 29187 | if (dumped == 0) cod_dump(gen_code); |
| 29188 | failed++; |
| 29189 | dumped++; |
| 29190 | } |
| 29191 | } |
| 29192 | } |
| 29193 | if (verbose) printf(" done\n"); |
| 29194 | cod_free_parse_context(context); |
| 29195 | cod_code_free(gen_code); |
| 29196 | } |
| 29197 | if ((only_run_test == NULL((void*)0)) || |
| 29198 | (strcmp(only_run_test, "i-uc") == 0)) { |
| 29199 | int i, j; |
| 29200 | static char code[] = "{\n\ |
| 29201 | int a = p1;\n\ |
| 29202 | unsigned char b = p2;\n\ |
| 29203 | return a - b;\n\ |
| 29204 | }"; |
| 29205 | |
| 29206 | int (*proc)(int a, unsigned char b); |
| 29207 | cod_parse_context context = new_cod_parse_context(); |
| 29208 | int dumped = 0; |
| 29209 | |
| 29210 | cod_code gen_code; |
| 29211 | |
| 29212 | /* test for int - unsigned char */ |
| 29213 | if (verbose) printf("test for int - unsigned char"); |
| 29214 | |
| 29215 | cod_assoc_externs(context, externs); |
| 29216 | cod_parse_for_context(extern_string, context); |
| 29217 | |
| 29218 | cod_subroutine_declaration("int proc(int p1, unsigned char p2)", |
| 29219 | context); |
| 29220 | gen_code = cod_code_gen(code, context); |
| 29221 | proc = (int (*)(int, unsigned char))(long)gen_code->func; |
| 29222 | |
| 29223 | |
| 29224 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 29225 | int source1_i = src1i_vals[i]; |
| 29226 | for (j=0 ; j < sizeof(src2uc_vals)/sizeof(src2uc_vals[0]) ; j++) { |
| 29227 | unsigned char source2_uc = src2uc_vals[j]; |
| 29228 | |
| 29229 | int expected_result; |
| 29230 | int result; |
| 29231 | |
| 29232 | |
| 29233 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 29234 | |
| 29235 | expected_result = (int) (source1_i - source2_uc); |
| 29236 | |
| 29237 | result = proc(source1_i, source2_uc); |
| 29238 | if (expected_result != result) { |
| 29239 | printf("Failed int - unsigned char test, expected %d, got %d, for %d - %u\n", |
| 29240 | expected_result, result, source1_i, source2_uc); |
| 29241 | if (dumped == 0) cod_dump(gen_code); |
| 29242 | failed++; |
| 29243 | dumped++; |
| 29244 | } |
| 29245 | } |
| 29246 | } |
| 29247 | if (verbose) printf(" done\n"); |
| 29248 | cod_free_parse_context(context); |
| 29249 | cod_code_free(gen_code); |
| 29250 | } |
| 29251 | if ((only_run_test == NULL((void*)0)) || |
| 29252 | (strcmp(only_run_test, "i-s") == 0)) { |
| 29253 | int i, j; |
| 29254 | static char code[] = "{\n\ |
| 29255 | int a = p1;\n\ |
| 29256 | short b = p2;\n\ |
| 29257 | return a - b;\n\ |
| 29258 | }"; |
| 29259 | |
| 29260 | int (*proc)(int a, short b); |
| 29261 | cod_parse_context context = new_cod_parse_context(); |
| 29262 | int dumped = 0; |
| 29263 | |
| 29264 | cod_code gen_code; |
| 29265 | |
| 29266 | /* test for int - short */ |
| 29267 | if (verbose) printf("test for int - short"); |
| 29268 | |
| 29269 | cod_assoc_externs(context, externs); |
| 29270 | cod_parse_for_context(extern_string, context); |
| 29271 | |
| 29272 | cod_subroutine_declaration("int proc(int p1, short p2)", |
| 29273 | context); |
| 29274 | gen_code = cod_code_gen(code, context); |
| 29275 | proc = (int (*)(int, short))(long)gen_code->func; |
| 29276 | |
| 29277 | |
| 29278 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 29279 | int source1_i = src1i_vals[i]; |
| 29280 | for (j=0 ; j < sizeof(src2s_vals)/sizeof(src2s_vals[0]) ; j++) { |
| 29281 | short source2_s = src2s_vals[j]; |
| 29282 | |
| 29283 | int expected_result; |
| 29284 | int result; |
| 29285 | |
| 29286 | |
| 29287 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 29288 | |
| 29289 | expected_result = (int) (source1_i - source2_s); |
| 29290 | |
| 29291 | result = proc(source1_i, source2_s); |
| 29292 | if (expected_result != result) { |
| 29293 | printf("Failed int - short test, expected %d, got %d, for %d - %d\n", |
| 29294 | expected_result, result, source1_i, source2_s); |
| 29295 | if (dumped == 0) cod_dump(gen_code); |
| 29296 | failed++; |
| 29297 | dumped++; |
| 29298 | } |
| 29299 | } |
| 29300 | } |
| 29301 | if (verbose) printf(" done\n"); |
| 29302 | cod_free_parse_context(context); |
| 29303 | cod_code_free(gen_code); |
| 29304 | } |
| 29305 | if ((only_run_test == NULL((void*)0)) || |
| 29306 | (strcmp(only_run_test, "i-us") == 0)) { |
| 29307 | int i, j; |
| 29308 | static char code[] = "{\n\ |
| 29309 | int a = p1;\n\ |
| 29310 | unsigned short b = p2;\n\ |
| 29311 | return a - b;\n\ |
| 29312 | }"; |
| 29313 | |
| 29314 | int (*proc)(int a, unsigned short b); |
| 29315 | cod_parse_context context = new_cod_parse_context(); |
| 29316 | int dumped = 0; |
| 29317 | |
| 29318 | cod_code gen_code; |
| 29319 | |
| 29320 | /* test for int - unsigned short */ |
| 29321 | if (verbose) printf("test for int - unsigned short"); |
| 29322 | |
| 29323 | cod_assoc_externs(context, externs); |
| 29324 | cod_parse_for_context(extern_string, context); |
| 29325 | |
| 29326 | cod_subroutine_declaration("int proc(int p1, unsigned short p2)", |
| 29327 | context); |
| 29328 | gen_code = cod_code_gen(code, context); |
| 29329 | proc = (int (*)(int, unsigned short))(long)gen_code->func; |
| 29330 | |
| 29331 | |
| 29332 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 29333 | int source1_i = src1i_vals[i]; |
| 29334 | for (j=0 ; j < sizeof(src2us_vals)/sizeof(src2us_vals[0]) ; j++) { |
| 29335 | unsigned short source2_us = src2us_vals[j]; |
| 29336 | |
| 29337 | int expected_result; |
| 29338 | int result; |
| 29339 | |
| 29340 | |
| 29341 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 29342 | |
| 29343 | expected_result = (int) (source1_i - source2_us); |
| 29344 | |
| 29345 | result = proc(source1_i, source2_us); |
| 29346 | if (expected_result != result) { |
| 29347 | printf("Failed int - unsigned short test, expected %d, got %d, for %d - %u\n", |
| 29348 | expected_result, result, source1_i, source2_us); |
| 29349 | if (dumped == 0) cod_dump(gen_code); |
| 29350 | failed++; |
| 29351 | dumped++; |
| 29352 | } |
| 29353 | } |
| 29354 | } |
| 29355 | if (verbose) printf(" done\n"); |
| 29356 | cod_free_parse_context(context); |
| 29357 | cod_code_free(gen_code); |
| 29358 | } |
| 29359 | if ((only_run_test == NULL((void*)0)) || |
| 29360 | (strcmp(only_run_test, "i-i") == 0)) { |
| 29361 | int i, j; |
| 29362 | static char code[] = "{\n\ |
| 29363 | int a = p1;\n\ |
| 29364 | int b = p2;\n\ |
| 29365 | return a - b;\n\ |
| 29366 | }"; |
| 29367 | |
| 29368 | int (*proc)(int a, int b); |
| 29369 | cod_parse_context context = new_cod_parse_context(); |
| 29370 | int dumped = 0; |
| 29371 | |
| 29372 | cod_code gen_code; |
| 29373 | |
| 29374 | /* test for int - int */ |
| 29375 | if (verbose) printf("test for int - int"); |
| 29376 | |
| 29377 | cod_assoc_externs(context, externs); |
| 29378 | cod_parse_for_context(extern_string, context); |
| 29379 | |
| 29380 | cod_subroutine_declaration("int proc(int p1, int p2)", |
| 29381 | context); |
| 29382 | gen_code = cod_code_gen(code, context); |
| 29383 | proc = (int (*)(int, int))(long)gen_code->func; |
| 29384 | |
| 29385 | |
| 29386 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 29387 | int source1_i = src1i_vals[i]; |
| 29388 | for (j=0 ; j < sizeof(src2i_vals)/sizeof(src2i_vals[0]) ; j++) { |
| 29389 | int source2_i = src2i_vals[j]; |
| 29390 | |
| 29391 | int expected_result; |
| 29392 | int result; |
| 29393 | |
| 29394 | |
| 29395 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 29396 | |
| 29397 | expected_result = (int) (source1_i - source2_i); |
| 29398 | |
| 29399 | result = proc(source1_i, source2_i); |
| 29400 | if (expected_result != result) { |
| 29401 | printf("Failed int - int test, expected %d, got %d, for %d - %d\n", |
| 29402 | expected_result, result, source1_i, source2_i); |
| 29403 | if (dumped == 0) cod_dump(gen_code); |
| 29404 | failed++; |
| 29405 | dumped++; |
| 29406 | } |
| 29407 | } |
| 29408 | } |
| 29409 | if (verbose) printf(" done\n"); |
| 29410 | cod_free_parse_context(context); |
| 29411 | cod_code_free(gen_code); |
| 29412 | } |
| 29413 | if ((only_run_test == NULL((void*)0)) || |
| 29414 | (strcmp(only_run_test, "i-u") == 0)) { |
| 29415 | int i, j; |
| 29416 | static char code[] = "{\n\ |
| 29417 | int a = p1;\n\ |
| 29418 | unsigned int b = p2;\n\ |
| 29419 | return a - b;\n\ |
| 29420 | }"; |
| 29421 | |
| 29422 | int (*proc)(int a, unsigned int b); |
| 29423 | cod_parse_context context = new_cod_parse_context(); |
| 29424 | int dumped = 0; |
| 29425 | |
| 29426 | cod_code gen_code; |
| 29427 | |
| 29428 | /* test for int - unsigned int */ |
| 29429 | if (verbose) printf("test for int - unsigned int"); |
| 29430 | |
| 29431 | cod_assoc_externs(context, externs); |
| 29432 | cod_parse_for_context(extern_string, context); |
| 29433 | |
| 29434 | cod_subroutine_declaration("int proc(int p1, unsigned int p2)", |
| 29435 | context); |
| 29436 | gen_code = cod_code_gen(code, context); |
| 29437 | proc = (int (*)(int, unsigned int))(long)gen_code->func; |
| 29438 | |
| 29439 | |
| 29440 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 29441 | int source1_i = src1i_vals[i]; |
| 29442 | for (j=0 ; j < sizeof(src2u_vals)/sizeof(src2u_vals[0]) ; j++) { |
| 29443 | unsigned int source2_u = src2u_vals[j]; |
| 29444 | |
| 29445 | int expected_result; |
| 29446 | int result; |
| 29447 | |
| 29448 | |
| 29449 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 29450 | |
| 29451 | expected_result = (int) (source1_i - source2_u); |
| 29452 | |
| 29453 | result = proc(source1_i, source2_u); |
| 29454 | if (expected_result != result) { |
| 29455 | printf("Failed int - unsigned int test, expected %d, got %d, for %d - %u\n", |
| 29456 | expected_result, result, source1_i, source2_u); |
| 29457 | if (dumped == 0) cod_dump(gen_code); |
| 29458 | failed++; |
| 29459 | dumped++; |
| 29460 | } |
| 29461 | } |
| 29462 | } |
| 29463 | if (verbose) printf(" done\n"); |
| 29464 | cod_free_parse_context(context); |
| 29465 | cod_code_free(gen_code); |
| 29466 | } |
| 29467 | if ((only_run_test == NULL((void*)0)) || |
| 29468 | (strcmp(only_run_test, "i-ul") == 0)) { |
| 29469 | int i, j; |
| 29470 | static char code[] = "{\n\ |
| 29471 | int a = p1;\n\ |
| 29472 | unsigned long b = p2;\n\ |
| 29473 | return a - b;\n\ |
| 29474 | }"; |
| 29475 | |
| 29476 | int (*proc)(int a, unsigned long b); |
| 29477 | cod_parse_context context = new_cod_parse_context(); |
| 29478 | int dumped = 0; |
| 29479 | |
| 29480 | cod_code gen_code; |
| 29481 | |
| 29482 | /* test for int - unsigned long */ |
| 29483 | if (verbose) printf("test for int - unsigned long"); |
| 29484 | |
| 29485 | cod_assoc_externs(context, externs); |
| 29486 | cod_parse_for_context(extern_string, context); |
| 29487 | |
| 29488 | cod_subroutine_declaration("int proc(int p1, unsigned long p2)", |
| 29489 | context); |
| 29490 | gen_code = cod_code_gen(code, context); |
| 29491 | proc = (int (*)(int, unsigned long))(long)gen_code->func; |
| 29492 | |
| 29493 | |
| 29494 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 29495 | int source1_i = src1i_vals[i]; |
| 29496 | for (j=0 ; j < sizeof(src2ul_vals)/sizeof(src2ul_vals[0]) ; j++) { |
| 29497 | unsigned long source2_ul = src2ul_vals[j]; |
| 29498 | |
| 29499 | int expected_result; |
| 29500 | int result; |
| 29501 | |
| 29502 | |
| 29503 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 29504 | |
| 29505 | expected_result = (int) (source1_i - source2_ul); |
| 29506 | |
| 29507 | result = proc(source1_i, source2_ul); |
| 29508 | if (expected_result != result) { |
| 29509 | printf("Failed int - unsigned long test, expected %d, got %d, for %d - %lu\n", |
| 29510 | expected_result, result, source1_i, source2_ul); |
| 29511 | if (dumped == 0) cod_dump(gen_code); |
| 29512 | failed++; |
| 29513 | dumped++; |
| 29514 | } |
| 29515 | } |
| 29516 | } |
| 29517 | if (verbose) printf(" done\n"); |
| 29518 | cod_free_parse_context(context); |
| 29519 | cod_code_free(gen_code); |
| 29520 | } |
| 29521 | if ((only_run_test == NULL((void*)0)) || |
| 29522 | (strcmp(only_run_test, "i-l") == 0)) { |
| 29523 | int i, j; |
| 29524 | static char code[] = "{\n\ |
| 29525 | int a = p1;\n\ |
| 29526 | long b = p2;\n\ |
| 29527 | return a - b;\n\ |
| 29528 | }"; |
| 29529 | |
| 29530 | int (*proc)(int a, long b); |
| 29531 | cod_parse_context context = new_cod_parse_context(); |
| 29532 | int dumped = 0; |
| 29533 | |
| 29534 | cod_code gen_code; |
| 29535 | |
| 29536 | /* test for int - long */ |
| 29537 | if (verbose) printf("test for int - long"); |
| 29538 | |
| 29539 | cod_assoc_externs(context, externs); |
| 29540 | cod_parse_for_context(extern_string, context); |
| 29541 | |
| 29542 | cod_subroutine_declaration("int proc(int p1, long p2)", |
| 29543 | context); |
| 29544 | gen_code = cod_code_gen(code, context); |
| 29545 | proc = (int (*)(int, long))(long)gen_code->func; |
| 29546 | |
| 29547 | |
| 29548 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 29549 | int source1_i = src1i_vals[i]; |
| 29550 | for (j=0 ; j < sizeof(src2l_vals)/sizeof(src2l_vals[0]) ; j++) { |
| 29551 | long source2_l = src2l_vals[j]; |
| 29552 | |
| 29553 | int expected_result; |
| 29554 | int result; |
| 29555 | |
| 29556 | |
| 29557 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 29558 | |
| 29559 | expected_result = (int) (source1_i - source2_l); |
| 29560 | |
| 29561 | result = proc(source1_i, source2_l); |
| 29562 | if (expected_result != result) { |
| 29563 | printf("Failed int - long test, expected %d, got %d, for %d - %ld\n", |
| 29564 | expected_result, result, source1_i, source2_l); |
| 29565 | if (dumped == 0) cod_dump(gen_code); |
| 29566 | failed++; |
| 29567 | dumped++; |
| 29568 | } |
| 29569 | } |
| 29570 | } |
| 29571 | if (verbose) printf(" done\n"); |
| 29572 | cod_free_parse_context(context); |
| 29573 | cod_code_free(gen_code); |
| 29574 | } |
| 29575 | if ((only_run_test == NULL((void*)0)) || |
| 29576 | (strcmp(only_run_test, "i-f") == 0)) { |
| 29577 | int i, j; |
| 29578 | static char code[] = "{\n\ |
| 29579 | int a = p1;\n\ |
| 29580 | float b = p2;\n\ |
| 29581 | return a - b;\n\ |
| 29582 | }"; |
| 29583 | |
| 29584 | int (*proc)(int a, float b); |
| 29585 | cod_parse_context context = new_cod_parse_context(); |
| 29586 | int dumped = 0; |
| 29587 | |
| 29588 | cod_code gen_code; |
| 29589 | |
| 29590 | /* test for int - float */ |
| 29591 | if (verbose) printf("test for int - float"); |
| 29592 | |
| 29593 | cod_assoc_externs(context, externs); |
| 29594 | cod_parse_for_context(extern_string, context); |
| 29595 | |
| 29596 | cod_subroutine_declaration("int proc(int p1, float p2)", |
| 29597 | context); |
| 29598 | gen_code = cod_code_gen(code, context); |
| 29599 | proc = (int (*)(int, float))(long)gen_code->func; |
| 29600 | |
| 29601 | |
| 29602 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 29603 | int source1_i = src1i_vals[i]; |
| 29604 | for (j=0 ; j < sizeof(src2f_vals)/sizeof(src2f_vals[0]) ; j++) { |
| 29605 | float source2_f = src2f_vals[j]; |
| 29606 | double range = 0.000001 * (fabs((double)source1_i) + fabs((double)source2_f)); |
| 29607 | int expected_result; |
| 29608 | int result; |
| 29609 | |
| 29610 | |
| 29611 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 29612 | |
| 29613 | expected_result = (int) (source1_i - source2_f); |
| 29614 | |
| 29615 | result = proc(source1_i, source2_f); |
| 29616 | range += 1.0; |
| 29617 | if ((result > (expected_result + range)) || (result < (expected_result - range))) { |
| 29618 | printf("Failed int - float test, expected %d, got %d, for %d - %g\n", |
| 29619 | expected_result, result, source1_i, source2_f); |
| 29620 | if (dumped == 0) cod_dump(gen_code); |
| 29621 | failed++; |
| 29622 | dumped++; |
| 29623 | } |
| 29624 | } |
| 29625 | } |
| 29626 | if (verbose) printf(" done\n"); |
| 29627 | cod_free_parse_context(context); |
| 29628 | cod_code_free(gen_code); |
| 29629 | } |
| 29630 | if ((only_run_test == NULL((void*)0)) || |
| 29631 | (strcmp(only_run_test, "i-d") == 0)) { |
| 29632 | int i, j; |
| 29633 | static char code[] = "{\n\ |
| 29634 | int a = p1;\n\ |
| 29635 | double b = p2;\n\ |
| 29636 | return a - b;\n\ |
| 29637 | }"; |
| 29638 | |
| 29639 | int (*proc)(int a, double b); |
| 29640 | cod_parse_context context = new_cod_parse_context(); |
| 29641 | int dumped = 0; |
| 29642 | |
| 29643 | cod_code gen_code; |
| 29644 | |
| 29645 | /* test for int - double */ |
| 29646 | if (verbose) printf("test for int - double"); |
| 29647 | |
| 29648 | cod_assoc_externs(context, externs); |
| 29649 | cod_parse_for_context(extern_string, context); |
| 29650 | |
| 29651 | cod_subroutine_declaration("int proc(int p1, double p2)", |
| 29652 | context); |
| 29653 | gen_code = cod_code_gen(code, context); |
| 29654 | proc = (int (*)(int, double))(long)gen_code->func; |
| 29655 | |
| 29656 | |
| 29657 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 29658 | int source1_i = src1i_vals[i]; |
| 29659 | for (j=0 ; j < sizeof(src2d_vals)/sizeof(src2d_vals[0]) ; j++) { |
| 29660 | double source2_d = src2d_vals[j]; |
| 29661 | |
| 29662 | int expected_result; |
| 29663 | int result; |
| 29664 | |
| 29665 | |
| 29666 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 29667 | |
| 29668 | expected_result = (int) (source1_i - source2_d); |
| 29669 | |
| 29670 | result = proc(source1_i, source2_d); |
| 29671 | if (expected_result != result) { |
| 29672 | printf("Failed int - double test, expected %d, got %d, for %d - %g\n", |
| 29673 | expected_result, result, source1_i, source2_d); |
| 29674 | if (dumped == 0) cod_dump(gen_code); |
| 29675 | failed++; |
| 29676 | dumped++; |
| 29677 | } |
| 29678 | } |
| 29679 | } |
| 29680 | if (verbose) printf(" done\n"); |
| 29681 | cod_free_parse_context(context); |
| 29682 | cod_code_free(gen_code); |
| 29683 | } |
| 29684 | } |
| 29685 | void sub_u_tests() |
| 29686 | { |
| 29687 | if ((only_run_test == NULL((void*)0)) || |
| 29688 | (strcmp(only_run_test, "u-c") == 0)) { |
| 29689 | int i, j; |
| 29690 | static char code[] = "{\n\ |
| 29691 | unsigned int a = p1;\n\ |
| 29692 | signed char b = p2;\n\ |
| 29693 | return a - b;\n\ |
| 29694 | }"; |
| 29695 | |
| 29696 | unsigned int (*proc)(unsigned int a, signed char b); |
| 29697 | cod_parse_context context = new_cod_parse_context(); |
| 29698 | int dumped = 0; |
| 29699 | |
| 29700 | cod_code gen_code; |
| 29701 | |
| 29702 | /* test for unsigned int - signed char */ |
| 29703 | if (verbose) printf("test for unsigned int - signed char"); |
| 29704 | |
| 29705 | cod_assoc_externs(context, externs); |
| 29706 | cod_parse_for_context(extern_string, context); |
| 29707 | |
| 29708 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, signed char p2)", |
| 29709 | context); |
| 29710 | gen_code = cod_code_gen(code, context); |
| 29711 | proc = (unsigned int (*)(unsigned int, signed char))(long)gen_code->func; |
| 29712 | |
| 29713 | |
| 29714 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 29715 | unsigned int source1_u = src1u_vals[i]; |
| 29716 | for (j=0 ; j < sizeof(src2c_vals)/sizeof(src2c_vals[0]) ; j++) { |
| 29717 | signed char source2_c = src2c_vals[j]; |
| 29718 | |
| 29719 | unsigned int expected_result; |
| 29720 | unsigned int result; |
| 29721 | |
| 29722 | |
| 29723 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 29724 | |
| 29725 | expected_result = (unsigned int) (source1_u - source2_c); |
| 29726 | |
| 29727 | result = proc(source1_u, source2_c); |
| 29728 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 29729 | if (expected_result != result) { |
| 29730 | printf("Failed unsigned int - signed char test, expected %u, got %u, for %u - %d\n", |
| 29731 | expected_result, result, source1_u, source2_c); |
| 29732 | if (dumped == 0) cod_dump(gen_code); |
| 29733 | failed++; |
| 29734 | dumped++; |
| 29735 | } |
| 29736 | } |
| 29737 | } |
| 29738 | if (verbose) printf(" done\n"); |
| 29739 | cod_free_parse_context(context); |
| 29740 | cod_code_free(gen_code); |
| 29741 | } |
| 29742 | if ((only_run_test == NULL((void*)0)) || |
| 29743 | (strcmp(only_run_test, "u-uc") == 0)) { |
| 29744 | int i, j; |
| 29745 | static char code[] = "{\n\ |
| 29746 | unsigned int a = p1;\n\ |
| 29747 | unsigned char b = p2;\n\ |
| 29748 | return a - b;\n\ |
| 29749 | }"; |
| 29750 | |
| 29751 | unsigned int (*proc)(unsigned int a, unsigned char b); |
| 29752 | cod_parse_context context = new_cod_parse_context(); |
| 29753 | int dumped = 0; |
| 29754 | |
| 29755 | cod_code gen_code; |
| 29756 | |
| 29757 | /* test for unsigned int - unsigned char */ |
| 29758 | if (verbose) printf("test for unsigned int - unsigned char"); |
| 29759 | |
| 29760 | cod_assoc_externs(context, externs); |
| 29761 | cod_parse_for_context(extern_string, context); |
| 29762 | |
| 29763 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, unsigned char p2)", |
| 29764 | context); |
| 29765 | gen_code = cod_code_gen(code, context); |
| 29766 | proc = (unsigned int (*)(unsigned int, unsigned char))(long)gen_code->func; |
| 29767 | |
| 29768 | |
| 29769 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 29770 | unsigned int source1_u = src1u_vals[i]; |
| 29771 | for (j=0 ; j < sizeof(src2uc_vals)/sizeof(src2uc_vals[0]) ; j++) { |
| 29772 | unsigned char source2_uc = src2uc_vals[j]; |
| 29773 | |
| 29774 | unsigned int expected_result; |
| 29775 | unsigned int result; |
| 29776 | |
| 29777 | |
| 29778 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 29779 | |
| 29780 | expected_result = (unsigned int) (source1_u - source2_uc); |
| 29781 | |
| 29782 | result = proc(source1_u, source2_uc); |
| 29783 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 29784 | if (expected_result != result) { |
| 29785 | printf("Failed unsigned int - unsigned char test, expected %u, got %u, for %u - %u\n", |
| 29786 | expected_result, result, source1_u, source2_uc); |
| 29787 | if (dumped == 0) cod_dump(gen_code); |
| 29788 | failed++; |
| 29789 | dumped++; |
| 29790 | } |
| 29791 | } |
| 29792 | } |
| 29793 | if (verbose) printf(" done\n"); |
| 29794 | cod_free_parse_context(context); |
| 29795 | cod_code_free(gen_code); |
| 29796 | } |
| 29797 | if ((only_run_test == NULL((void*)0)) || |
| 29798 | (strcmp(only_run_test, "u-s") == 0)) { |
| 29799 | int i, j; |
| 29800 | static char code[] = "{\n\ |
| 29801 | unsigned int a = p1;\n\ |
| 29802 | short b = p2;\n\ |
| 29803 | return a - b;\n\ |
| 29804 | }"; |
| 29805 | |
| 29806 | unsigned int (*proc)(unsigned int a, short b); |
| 29807 | cod_parse_context context = new_cod_parse_context(); |
| 29808 | int dumped = 0; |
| 29809 | |
| 29810 | cod_code gen_code; |
| 29811 | |
| 29812 | /* test for unsigned int - short */ |
| 29813 | if (verbose) printf("test for unsigned int - short"); |
| 29814 | |
| 29815 | cod_assoc_externs(context, externs); |
| 29816 | cod_parse_for_context(extern_string, context); |
| 29817 | |
| 29818 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, short p2)", |
| 29819 | context); |
| 29820 | gen_code = cod_code_gen(code, context); |
| 29821 | proc = (unsigned int (*)(unsigned int, short))(long)gen_code->func; |
| 29822 | |
| 29823 | |
| 29824 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 29825 | unsigned int source1_u = src1u_vals[i]; |
| 29826 | for (j=0 ; j < sizeof(src2s_vals)/sizeof(src2s_vals[0]) ; j++) { |
| 29827 | short source2_s = src2s_vals[j]; |
| 29828 | |
| 29829 | unsigned int expected_result; |
| 29830 | unsigned int result; |
| 29831 | |
| 29832 | |
| 29833 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 29834 | |
| 29835 | expected_result = (unsigned int) (source1_u - source2_s); |
| 29836 | |
| 29837 | result = proc(source1_u, source2_s); |
| 29838 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 29839 | if (expected_result != result) { |
| 29840 | printf("Failed unsigned int - short test, expected %u, got %u, for %u - %d\n", |
| 29841 | expected_result, result, source1_u, source2_s); |
| 29842 | if (dumped == 0) cod_dump(gen_code); |
| 29843 | failed++; |
| 29844 | dumped++; |
| 29845 | } |
| 29846 | } |
| 29847 | } |
| 29848 | if (verbose) printf(" done\n"); |
| 29849 | cod_free_parse_context(context); |
| 29850 | cod_code_free(gen_code); |
| 29851 | } |
| 29852 | if ((only_run_test == NULL((void*)0)) || |
| 29853 | (strcmp(only_run_test, "u-us") == 0)) { |
| 29854 | int i, j; |
| 29855 | static char code[] = "{\n\ |
| 29856 | unsigned int a = p1;\n\ |
| 29857 | unsigned short b = p2;\n\ |
| 29858 | return a - b;\n\ |
| 29859 | }"; |
| 29860 | |
| 29861 | unsigned int (*proc)(unsigned int a, unsigned short b); |
| 29862 | cod_parse_context context = new_cod_parse_context(); |
| 29863 | int dumped = 0; |
| 29864 | |
| 29865 | cod_code gen_code; |
| 29866 | |
| 29867 | /* test for unsigned int - unsigned short */ |
| 29868 | if (verbose) printf("test for unsigned int - unsigned short"); |
| 29869 | |
| 29870 | cod_assoc_externs(context, externs); |
| 29871 | cod_parse_for_context(extern_string, context); |
| 29872 | |
| 29873 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, unsigned short p2)", |
| 29874 | context); |
| 29875 | gen_code = cod_code_gen(code, context); |
| 29876 | proc = (unsigned int (*)(unsigned int, unsigned short))(long)gen_code->func; |
| 29877 | |
| 29878 | |
| 29879 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 29880 | unsigned int source1_u = src1u_vals[i]; |
| 29881 | for (j=0 ; j < sizeof(src2us_vals)/sizeof(src2us_vals[0]) ; j++) { |
| 29882 | unsigned short source2_us = src2us_vals[j]; |
| 29883 | |
| 29884 | unsigned int expected_result; |
| 29885 | unsigned int result; |
| 29886 | |
| 29887 | |
| 29888 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 29889 | |
| 29890 | expected_result = (unsigned int) (source1_u - source2_us); |
| 29891 | |
| 29892 | result = proc(source1_u, source2_us); |
| 29893 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 29894 | if (expected_result != result) { |
| 29895 | printf("Failed unsigned int - unsigned short test, expected %u, got %u, for %u - %u\n", |
| 29896 | expected_result, result, source1_u, source2_us); |
| 29897 | if (dumped == 0) cod_dump(gen_code); |
| 29898 | failed++; |
| 29899 | dumped++; |
| 29900 | } |
| 29901 | } |
| 29902 | } |
| 29903 | if (verbose) printf(" done\n"); |
| 29904 | cod_free_parse_context(context); |
| 29905 | cod_code_free(gen_code); |
| 29906 | } |
| 29907 | if ((only_run_test == NULL((void*)0)) || |
| 29908 | (strcmp(only_run_test, "u-i") == 0)) { |
| 29909 | int i, j; |
| 29910 | static char code[] = "{\n\ |
| 29911 | unsigned int a = p1;\n\ |
| 29912 | int b = p2;\n\ |
| 29913 | return a - b;\n\ |
| 29914 | }"; |
| 29915 | |
| 29916 | unsigned int (*proc)(unsigned int a, int b); |
| 29917 | cod_parse_context context = new_cod_parse_context(); |
| 29918 | int dumped = 0; |
| 29919 | |
| 29920 | cod_code gen_code; |
| 29921 | |
| 29922 | /* test for unsigned int - int */ |
| 29923 | if (verbose) printf("test for unsigned int - int"); |
| 29924 | |
| 29925 | cod_assoc_externs(context, externs); |
| 29926 | cod_parse_for_context(extern_string, context); |
| 29927 | |
| 29928 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, int p2)", |
| 29929 | context); |
| 29930 | gen_code = cod_code_gen(code, context); |
| 29931 | proc = (unsigned int (*)(unsigned int, int))(long)gen_code->func; |
| 29932 | |
| 29933 | |
| 29934 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 29935 | unsigned int source1_u = src1u_vals[i]; |
| 29936 | for (j=0 ; j < sizeof(src2i_vals)/sizeof(src2i_vals[0]) ; j++) { |
| 29937 | int source2_i = src2i_vals[j]; |
| 29938 | |
| 29939 | unsigned int expected_result; |
| 29940 | unsigned int result; |
| 29941 | |
| 29942 | |
| 29943 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 29944 | |
| 29945 | expected_result = (unsigned int) (source1_u - source2_i); |
| 29946 | |
| 29947 | result = proc(source1_u, source2_i); |
| 29948 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 29949 | if (expected_result != result) { |
| 29950 | printf("Failed unsigned int - int test, expected %u, got %u, for %u - %d\n", |
| 29951 | expected_result, result, source1_u, source2_i); |
| 29952 | if (dumped == 0) cod_dump(gen_code); |
| 29953 | failed++; |
| 29954 | dumped++; |
| 29955 | } |
| 29956 | } |
| 29957 | } |
| 29958 | if (verbose) printf(" done\n"); |
| 29959 | cod_free_parse_context(context); |
| 29960 | cod_code_free(gen_code); |
| 29961 | } |
| 29962 | if ((only_run_test == NULL((void*)0)) || |
| 29963 | (strcmp(only_run_test, "u-u") == 0)) { |
| 29964 | int i, j; |
| 29965 | static char code[] = "{\n\ |
| 29966 | unsigned int a = p1;\n\ |
| 29967 | unsigned int b = p2;\n\ |
| 29968 | return a - b;\n\ |
| 29969 | }"; |
| 29970 | |
| 29971 | unsigned int (*proc)(unsigned int a, unsigned int b); |
| 29972 | cod_parse_context context = new_cod_parse_context(); |
| 29973 | int dumped = 0; |
| 29974 | |
| 29975 | cod_code gen_code; |
| 29976 | |
| 29977 | /* test for unsigned int - unsigned int */ |
| 29978 | if (verbose) printf("test for unsigned int - unsigned int"); |
| 29979 | |
| 29980 | cod_assoc_externs(context, externs); |
| 29981 | cod_parse_for_context(extern_string, context); |
| 29982 | |
| 29983 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, unsigned int p2)", |
| 29984 | context); |
| 29985 | gen_code = cod_code_gen(code, context); |
| 29986 | proc = (unsigned int (*)(unsigned int, unsigned int))(long)gen_code->func; |
| 29987 | |
| 29988 | |
| 29989 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 29990 | unsigned int source1_u = src1u_vals[i]; |
| 29991 | for (j=0 ; j < sizeof(src2u_vals)/sizeof(src2u_vals[0]) ; j++) { |
| 29992 | unsigned int source2_u = src2u_vals[j]; |
| 29993 | |
| 29994 | unsigned int expected_result; |
| 29995 | unsigned int result; |
| 29996 | |
| 29997 | |
| 29998 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 29999 | |
| 30000 | expected_result = (unsigned int) (source1_u - source2_u); |
| 30001 | |
| 30002 | result = proc(source1_u, source2_u); |
| 30003 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 30004 | if (expected_result != result) { |
| 30005 | printf("Failed unsigned int - unsigned int test, expected %u, got %u, for %u - %u\n", |
| 30006 | expected_result, result, source1_u, source2_u); |
| 30007 | if (dumped == 0) cod_dump(gen_code); |
| 30008 | failed++; |
| 30009 | dumped++; |
| 30010 | } |
| 30011 | } |
| 30012 | } |
| 30013 | if (verbose) printf(" done\n"); |
| 30014 | cod_free_parse_context(context); |
| 30015 | cod_code_free(gen_code); |
| 30016 | } |
| 30017 | if ((only_run_test == NULL((void*)0)) || |
| 30018 | (strcmp(only_run_test, "u-ul") == 0)) { |
| 30019 | int i, j; |
| 30020 | static char code[] = "{\n\ |
| 30021 | unsigned int a = p1;\n\ |
| 30022 | unsigned long b = p2;\n\ |
| 30023 | return a - b;\n\ |
| 30024 | }"; |
| 30025 | |
| 30026 | unsigned int (*proc)(unsigned int a, unsigned long b); |
| 30027 | cod_parse_context context = new_cod_parse_context(); |
| 30028 | int dumped = 0; |
| 30029 | |
| 30030 | cod_code gen_code; |
| 30031 | |
| 30032 | /* test for unsigned int - unsigned long */ |
| 30033 | if (verbose) printf("test for unsigned int - unsigned long"); |
| 30034 | |
| 30035 | cod_assoc_externs(context, externs); |
| 30036 | cod_parse_for_context(extern_string, context); |
| 30037 | |
| 30038 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, unsigned long p2)", |
| 30039 | context); |
| 30040 | gen_code = cod_code_gen(code, context); |
| 30041 | proc = (unsigned int (*)(unsigned int, unsigned long))(long)gen_code->func; |
| 30042 | |
| 30043 | |
| 30044 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 30045 | unsigned int source1_u = src1u_vals[i]; |
| 30046 | for (j=0 ; j < sizeof(src2ul_vals)/sizeof(src2ul_vals[0]) ; j++) { |
| 30047 | unsigned long source2_ul = src2ul_vals[j]; |
| 30048 | |
| 30049 | unsigned int expected_result; |
| 30050 | unsigned int result; |
| 30051 | |
| 30052 | |
| 30053 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 30054 | |
| 30055 | expected_result = (unsigned int) (source1_u - source2_ul); |
| 30056 | |
| 30057 | result = proc(source1_u, source2_ul); |
| 30058 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 30059 | if (expected_result != result) { |
| 30060 | printf("Failed unsigned int - unsigned long test, expected %u, got %u, for %u - %lu\n", |
| 30061 | expected_result, result, source1_u, source2_ul); |
| 30062 | if (dumped == 0) cod_dump(gen_code); |
| 30063 | failed++; |
| 30064 | dumped++; |
| 30065 | } |
| 30066 | } |
| 30067 | } |
| 30068 | if (verbose) printf(" done\n"); |
| 30069 | cod_free_parse_context(context); |
| 30070 | cod_code_free(gen_code); |
| 30071 | } |
| 30072 | if ((only_run_test == NULL((void*)0)) || |
| 30073 | (strcmp(only_run_test, "u-l") == 0)) { |
| 30074 | int i, j; |
| 30075 | static char code[] = "{\n\ |
| 30076 | unsigned int a = p1;\n\ |
| 30077 | long b = p2;\n\ |
| 30078 | return a - b;\n\ |
| 30079 | }"; |
| 30080 | |
| 30081 | unsigned int (*proc)(unsigned int a, long b); |
| 30082 | cod_parse_context context = new_cod_parse_context(); |
| 30083 | int dumped = 0; |
| 30084 | |
| 30085 | cod_code gen_code; |
| 30086 | |
| 30087 | /* test for unsigned int - long */ |
| 30088 | if (verbose) printf("test for unsigned int - long"); |
| 30089 | |
| 30090 | cod_assoc_externs(context, externs); |
| 30091 | cod_parse_for_context(extern_string, context); |
| 30092 | |
| 30093 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, long p2)", |
| 30094 | context); |
| 30095 | gen_code = cod_code_gen(code, context); |
| 30096 | proc = (unsigned int (*)(unsigned int, long))(long)gen_code->func; |
| 30097 | |
| 30098 | |
| 30099 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 30100 | unsigned int source1_u = src1u_vals[i]; |
| 30101 | for (j=0 ; j < sizeof(src2l_vals)/sizeof(src2l_vals[0]) ; j++) { |
| 30102 | long source2_l = src2l_vals[j]; |
| 30103 | |
| 30104 | unsigned int expected_result; |
| 30105 | unsigned int result; |
| 30106 | |
| 30107 | |
| 30108 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 30109 | |
| 30110 | expected_result = (unsigned int) (source1_u - source2_l); |
| 30111 | |
| 30112 | result = proc(source1_u, source2_l); |
| 30113 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 30114 | if (expected_result != result) { |
| 30115 | printf("Failed unsigned int - long test, expected %u, got %u, for %u - %ld\n", |
| 30116 | expected_result, result, source1_u, source2_l); |
| 30117 | if (dumped == 0) cod_dump(gen_code); |
| 30118 | failed++; |
| 30119 | dumped++; |
| 30120 | } |
| 30121 | } |
| 30122 | } |
| 30123 | if (verbose) printf(" done\n"); |
| 30124 | cod_free_parse_context(context); |
| 30125 | cod_code_free(gen_code); |
| 30126 | } |
| 30127 | if ((only_run_test == NULL((void*)0)) || |
| 30128 | (strcmp(only_run_test, "u-f") == 0)) { |
| 30129 | int i, j; |
| 30130 | static char code[] = "{\n\ |
| 30131 | unsigned int a = p1;\n\ |
| 30132 | float b = p2;\n\ |
| 30133 | return a - b;\n\ |
| 30134 | }"; |
| 30135 | |
| 30136 | unsigned int (*proc)(unsigned int a, float b); |
| 30137 | cod_parse_context context = new_cod_parse_context(); |
| 30138 | int dumped = 0; |
| 30139 | |
| 30140 | cod_code gen_code; |
| 30141 | |
| 30142 | /* test for unsigned int - float */ |
| 30143 | if (verbose) printf("test for unsigned int - float"); |
| 30144 | |
| 30145 | cod_assoc_externs(context, externs); |
| 30146 | cod_parse_for_context(extern_string, context); |
| 30147 | |
| 30148 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, float p2)", |
| 30149 | context); |
| 30150 | gen_code = cod_code_gen(code, context); |
| 30151 | proc = (unsigned int (*)(unsigned int, float))(long)gen_code->func; |
| 30152 | |
| 30153 | |
| 30154 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 30155 | unsigned int source1_u = src1u_vals[i]; |
| 30156 | for (j=0 ; j < sizeof(src2f_vals)/sizeof(src2f_vals[0]) ; j++) { |
| 30157 | float source2_f = src2f_vals[j]; |
| 30158 | double range = 0.000001 * (fabs((double)source1_u) + fabs((double)source2_f)); |
| 30159 | unsigned int expected_result; |
| 30160 | unsigned int result; |
| 30161 | |
| 30162 | |
| 30163 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 30164 | |
| 30165 | expected_result = (unsigned int) (source1_u - source2_f); |
| 30166 | |
| 30167 | result = proc(source1_u, source2_f); |
| 30168 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 30169 | range += 1.0; |
| 30170 | if ((result > (expected_result + range)) || (result < (expected_result - range))) { |
| 30171 | printf("Failed unsigned int - float test, expected %u, got %u, for %u - %g\n", |
| 30172 | expected_result, result, source1_u, source2_f); |
| 30173 | if (dumped == 0) cod_dump(gen_code); |
| 30174 | failed++; |
| 30175 | dumped++; |
| 30176 | } |
| 30177 | } |
| 30178 | } |
| 30179 | if (verbose) printf(" done\n"); |
| 30180 | cod_free_parse_context(context); |
| 30181 | cod_code_free(gen_code); |
| 30182 | } |
| 30183 | if ((only_run_test == NULL((void*)0)) || |
| 30184 | (strcmp(only_run_test, "u-d") == 0)) { |
| 30185 | int i, j; |
| 30186 | static char code[] = "{\n\ |
| 30187 | unsigned int a = p1;\n\ |
| 30188 | double b = p2;\n\ |
| 30189 | return a - b;\n\ |
| 30190 | }"; |
| 30191 | |
| 30192 | unsigned int (*proc)(unsigned int a, double b); |
| 30193 | cod_parse_context context = new_cod_parse_context(); |
| 30194 | int dumped = 0; |
| 30195 | |
| 30196 | cod_code gen_code; |
| 30197 | |
| 30198 | /* test for unsigned int - double */ |
| 30199 | if (verbose) printf("test for unsigned int - double"); |
| 30200 | |
| 30201 | cod_assoc_externs(context, externs); |
| 30202 | cod_parse_for_context(extern_string, context); |
| 30203 | |
| 30204 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, double p2)", |
| 30205 | context); |
| 30206 | gen_code = cod_code_gen(code, context); |
| 30207 | proc = (unsigned int (*)(unsigned int, double))(long)gen_code->func; |
| 30208 | |
| 30209 | |
| 30210 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 30211 | unsigned int source1_u = src1u_vals[i]; |
| 30212 | for (j=0 ; j < sizeof(src2d_vals)/sizeof(src2d_vals[0]) ; j++) { |
| 30213 | double source2_d = src2d_vals[j]; |
| 30214 | |
| 30215 | unsigned int expected_result; |
| 30216 | unsigned int result; |
| 30217 | |
| 30218 | |
| 30219 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 30220 | |
| 30221 | expected_result = (unsigned int) (source1_u - source2_d); |
| 30222 | |
| 30223 | result = proc(source1_u, source2_d); |
| 30224 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 30225 | if (expected_result != result) { |
| 30226 | printf("Failed unsigned int - double test, expected %u, got %u, for %u - %g\n", |
| 30227 | expected_result, result, source1_u, source2_d); |
| 30228 | if (dumped == 0) cod_dump(gen_code); |
| 30229 | failed++; |
| 30230 | dumped++; |
| 30231 | } |
| 30232 | } |
| 30233 | } |
| 30234 | if (verbose) printf(" done\n"); |
| 30235 | cod_free_parse_context(context); |
| 30236 | cod_code_free(gen_code); |
| 30237 | } |
| 30238 | } |
| 30239 | void sub_ul_tests() |
| 30240 | { |
| 30241 | if ((only_run_test == NULL((void*)0)) || |
| 30242 | (strcmp(only_run_test, "ul-c") == 0)) { |
| 30243 | int i, j; |
| 30244 | static char code[] = "{\n\ |
| 30245 | unsigned long a = p1;\n\ |
| 30246 | signed char b = p2;\n\ |
| 30247 | return a - b;\n\ |
| 30248 | }"; |
| 30249 | |
| 30250 | unsigned long (*proc)(unsigned long a, signed char b); |
| 30251 | cod_parse_context context = new_cod_parse_context(); |
| 30252 | int dumped = 0; |
| 30253 | |
| 30254 | cod_code gen_code; |
| 30255 | |
| 30256 | /* test for unsigned long - signed char */ |
| 30257 | if (verbose) printf("test for unsigned long - signed char"); |
| 30258 | |
| 30259 | cod_assoc_externs(context, externs); |
| 30260 | cod_parse_for_context(extern_string, context); |
| 30261 | |
| 30262 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, signed char p2)", |
| 30263 | context); |
| 30264 | gen_code = cod_code_gen(code, context); |
| 30265 | proc = (unsigned long (*)(unsigned long, signed char))(long)gen_code->func; |
| 30266 | |
| 30267 | |
| 30268 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 30269 | unsigned long source1_ul = src1ul_vals[i]; |
| 30270 | for (j=0 ; j < sizeof(src2c_vals)/sizeof(src2c_vals[0]) ; j++) { |
| 30271 | signed char source2_c = src2c_vals[j]; |
| 30272 | |
| 30273 | unsigned long expected_result; |
| 30274 | unsigned long result; |
| 30275 | |
| 30276 | |
| 30277 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 30278 | |
| 30279 | expected_result = (unsigned long) (source1_ul - source2_c); |
| 30280 | |
| 30281 | result = proc(source1_ul, source2_c); |
| 30282 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 30283 | if (expected_result != result) { |
| 30284 | printf("Failed unsigned long - signed char test, expected %lu, got %lu, for %lu - %d\n", |
| 30285 | expected_result, result, source1_ul, source2_c); |
| 30286 | if (dumped == 0) cod_dump(gen_code); |
| 30287 | failed++; |
| 30288 | dumped++; |
| 30289 | } |
| 30290 | } |
| 30291 | } |
| 30292 | if (verbose) printf(" done\n"); |
| 30293 | cod_free_parse_context(context); |
| 30294 | cod_code_free(gen_code); |
| 30295 | } |
| 30296 | if ((only_run_test == NULL((void*)0)) || |
| 30297 | (strcmp(only_run_test, "ul-uc") == 0)) { |
| 30298 | int i, j; |
| 30299 | static char code[] = "{\n\ |
| 30300 | unsigned long a = p1;\n\ |
| 30301 | unsigned char b = p2;\n\ |
| 30302 | return a - b;\n\ |
| 30303 | }"; |
| 30304 | |
| 30305 | unsigned long (*proc)(unsigned long a, unsigned char b); |
| 30306 | cod_parse_context context = new_cod_parse_context(); |
| 30307 | int dumped = 0; |
| 30308 | |
| 30309 | cod_code gen_code; |
| 30310 | |
| 30311 | /* test for unsigned long - unsigned char */ |
| 30312 | if (verbose) printf("test for unsigned long - unsigned char"); |
| 30313 | |
| 30314 | cod_assoc_externs(context, externs); |
| 30315 | cod_parse_for_context(extern_string, context); |
| 30316 | |
| 30317 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, unsigned char p2)", |
| 30318 | context); |
| 30319 | gen_code = cod_code_gen(code, context); |
| 30320 | proc = (unsigned long (*)(unsigned long, unsigned char))(long)gen_code->func; |
| 30321 | |
| 30322 | |
| 30323 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 30324 | unsigned long source1_ul = src1ul_vals[i]; |
| 30325 | for (j=0 ; j < sizeof(src2uc_vals)/sizeof(src2uc_vals[0]) ; j++) { |
| 30326 | unsigned char source2_uc = src2uc_vals[j]; |
| 30327 | |
| 30328 | unsigned long expected_result; |
| 30329 | unsigned long result; |
| 30330 | |
| 30331 | |
| 30332 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 30333 | |
| 30334 | expected_result = (unsigned long) (source1_ul - source2_uc); |
| 30335 | |
| 30336 | result = proc(source1_ul, source2_uc); |
| 30337 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 30338 | if (expected_result != result) { |
| 30339 | printf("Failed unsigned long - unsigned char test, expected %lu, got %lu, for %lu - %u\n", |
| 30340 | expected_result, result, source1_ul, source2_uc); |
| 30341 | if (dumped == 0) cod_dump(gen_code); |
| 30342 | failed++; |
| 30343 | dumped++; |
| 30344 | } |
| 30345 | } |
| 30346 | } |
| 30347 | if (verbose) printf(" done\n"); |
| 30348 | cod_free_parse_context(context); |
| 30349 | cod_code_free(gen_code); |
| 30350 | } |
| 30351 | if ((only_run_test == NULL((void*)0)) || |
| 30352 | (strcmp(only_run_test, "ul-s") == 0)) { |
| 30353 | int i, j; |
| 30354 | static char code[] = "{\n\ |
| 30355 | unsigned long a = p1;\n\ |
| 30356 | short b = p2;\n\ |
| 30357 | return a - b;\n\ |
| 30358 | }"; |
| 30359 | |
| 30360 | unsigned long (*proc)(unsigned long a, short b); |
| 30361 | cod_parse_context context = new_cod_parse_context(); |
| 30362 | int dumped = 0; |
| 30363 | |
| 30364 | cod_code gen_code; |
| 30365 | |
| 30366 | /* test for unsigned long - short */ |
| 30367 | if (verbose) printf("test for unsigned long - short"); |
| 30368 | |
| 30369 | cod_assoc_externs(context, externs); |
| 30370 | cod_parse_for_context(extern_string, context); |
| 30371 | |
| 30372 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, short p2)", |
| 30373 | context); |
| 30374 | gen_code = cod_code_gen(code, context); |
| 30375 | proc = (unsigned long (*)(unsigned long, short))(long)gen_code->func; |
| 30376 | |
| 30377 | |
| 30378 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 30379 | unsigned long source1_ul = src1ul_vals[i]; |
| 30380 | for (j=0 ; j < sizeof(src2s_vals)/sizeof(src2s_vals[0]) ; j++) { |
| 30381 | short source2_s = src2s_vals[j]; |
| 30382 | |
| 30383 | unsigned long expected_result; |
| 30384 | unsigned long result; |
| 30385 | |
| 30386 | |
| 30387 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 30388 | |
| 30389 | expected_result = (unsigned long) (source1_ul - source2_s); |
| 30390 | |
| 30391 | result = proc(source1_ul, source2_s); |
| 30392 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 30393 | if (expected_result != result) { |
| 30394 | printf("Failed unsigned long - short test, expected %lu, got %lu, for %lu - %d\n", |
| 30395 | expected_result, result, source1_ul, source2_s); |
| 30396 | if (dumped == 0) cod_dump(gen_code); |
| 30397 | failed++; |
| 30398 | dumped++; |
| 30399 | } |
| 30400 | } |
| 30401 | } |
| 30402 | if (verbose) printf(" done\n"); |
| 30403 | cod_free_parse_context(context); |
| 30404 | cod_code_free(gen_code); |
| 30405 | } |
| 30406 | if ((only_run_test == NULL((void*)0)) || |
| 30407 | (strcmp(only_run_test, "ul-us") == 0)) { |
| 30408 | int i, j; |
| 30409 | static char code[] = "{\n\ |
| 30410 | unsigned long a = p1;\n\ |
| 30411 | unsigned short b = p2;\n\ |
| 30412 | return a - b;\n\ |
| 30413 | }"; |
| 30414 | |
| 30415 | unsigned long (*proc)(unsigned long a, unsigned short b); |
| 30416 | cod_parse_context context = new_cod_parse_context(); |
| 30417 | int dumped = 0; |
| 30418 | |
| 30419 | cod_code gen_code; |
| 30420 | |
| 30421 | /* test for unsigned long - unsigned short */ |
| 30422 | if (verbose) printf("test for unsigned long - unsigned short"); |
| 30423 | |
| 30424 | cod_assoc_externs(context, externs); |
| 30425 | cod_parse_for_context(extern_string, context); |
| 30426 | |
| 30427 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, unsigned short p2)", |
| 30428 | context); |
| 30429 | gen_code = cod_code_gen(code, context); |
| 30430 | proc = (unsigned long (*)(unsigned long, unsigned short))(long)gen_code->func; |
| 30431 | |
| 30432 | |
| 30433 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 30434 | unsigned long source1_ul = src1ul_vals[i]; |
| 30435 | for (j=0 ; j < sizeof(src2us_vals)/sizeof(src2us_vals[0]) ; j++) { |
| 30436 | unsigned short source2_us = src2us_vals[j]; |
| 30437 | |
| 30438 | unsigned long expected_result; |
| 30439 | unsigned long result; |
| 30440 | |
| 30441 | |
| 30442 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 30443 | |
| 30444 | expected_result = (unsigned long) (source1_ul - source2_us); |
| 30445 | |
| 30446 | result = proc(source1_ul, source2_us); |
| 30447 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 30448 | if (expected_result != result) { |
| 30449 | printf("Failed unsigned long - unsigned short test, expected %lu, got %lu, for %lu - %u\n", |
| 30450 | expected_result, result, source1_ul, source2_us); |
| 30451 | if (dumped == 0) cod_dump(gen_code); |
| 30452 | failed++; |
| 30453 | dumped++; |
| 30454 | } |
| 30455 | } |
| 30456 | } |
| 30457 | if (verbose) printf(" done\n"); |
| 30458 | cod_free_parse_context(context); |
| 30459 | cod_code_free(gen_code); |
| 30460 | } |
| 30461 | if ((only_run_test == NULL((void*)0)) || |
| 30462 | (strcmp(only_run_test, "ul-i") == 0)) { |
| 30463 | int i, j; |
| 30464 | static char code[] = "{\n\ |
| 30465 | unsigned long a = p1;\n\ |
| 30466 | int b = p2;\n\ |
| 30467 | return a - b;\n\ |
| 30468 | }"; |
| 30469 | |
| 30470 | unsigned long (*proc)(unsigned long a, int b); |
| 30471 | cod_parse_context context = new_cod_parse_context(); |
| 30472 | int dumped = 0; |
| 30473 | |
| 30474 | cod_code gen_code; |
| 30475 | |
| 30476 | /* test for unsigned long - int */ |
| 30477 | if (verbose) printf("test for unsigned long - int"); |
| 30478 | |
| 30479 | cod_assoc_externs(context, externs); |
| 30480 | cod_parse_for_context(extern_string, context); |
| 30481 | |
| 30482 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, int p2)", |
| 30483 | context); |
| 30484 | gen_code = cod_code_gen(code, context); |
| 30485 | proc = (unsigned long (*)(unsigned long, int))(long)gen_code->func; |
| 30486 | |
| 30487 | |
| 30488 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 30489 | unsigned long source1_ul = src1ul_vals[i]; |
| 30490 | for (j=0 ; j < sizeof(src2i_vals)/sizeof(src2i_vals[0]) ; j++) { |
| 30491 | int source2_i = src2i_vals[j]; |
| 30492 | |
| 30493 | unsigned long expected_result; |
| 30494 | unsigned long result; |
| 30495 | |
| 30496 | |
| 30497 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 30498 | |
| 30499 | expected_result = (unsigned long) (source1_ul - source2_i); |
| 30500 | |
| 30501 | result = proc(source1_ul, source2_i); |
| 30502 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 30503 | if (expected_result != result) { |
| 30504 | printf("Failed unsigned long - int test, expected %lu, got %lu, for %lu - %d\n", |
| 30505 | expected_result, result, source1_ul, source2_i); |
| 30506 | if (dumped == 0) cod_dump(gen_code); |
| 30507 | failed++; |
| 30508 | dumped++; |
| 30509 | } |
| 30510 | } |
| 30511 | } |
| 30512 | if (verbose) printf(" done\n"); |
| 30513 | cod_free_parse_context(context); |
| 30514 | cod_code_free(gen_code); |
| 30515 | } |
| 30516 | if ((only_run_test == NULL((void*)0)) || |
| 30517 | (strcmp(only_run_test, "ul-u") == 0)) { |
| 30518 | int i, j; |
| 30519 | static char code[] = "{\n\ |
| 30520 | unsigned long a = p1;\n\ |
| 30521 | unsigned int b = p2;\n\ |
| 30522 | return a - b;\n\ |
| 30523 | }"; |
| 30524 | |
| 30525 | unsigned long (*proc)(unsigned long a, unsigned int b); |
| 30526 | cod_parse_context context = new_cod_parse_context(); |
| 30527 | int dumped = 0; |
| 30528 | |
| 30529 | cod_code gen_code; |
| 30530 | |
| 30531 | /* test for unsigned long - unsigned int */ |
| 30532 | if (verbose) printf("test for unsigned long - unsigned int"); |
| 30533 | |
| 30534 | cod_assoc_externs(context, externs); |
| 30535 | cod_parse_for_context(extern_string, context); |
| 30536 | |
| 30537 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, unsigned int p2)", |
| 30538 | context); |
| 30539 | gen_code = cod_code_gen(code, context); |
| 30540 | proc = (unsigned long (*)(unsigned long, unsigned int))(long)gen_code->func; |
| 30541 | |
| 30542 | |
| 30543 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 30544 | unsigned long source1_ul = src1ul_vals[i]; |
| 30545 | for (j=0 ; j < sizeof(src2u_vals)/sizeof(src2u_vals[0]) ; j++) { |
| 30546 | unsigned int source2_u = src2u_vals[j]; |
| 30547 | |
| 30548 | unsigned long expected_result; |
| 30549 | unsigned long result; |
| 30550 | |
| 30551 | |
| 30552 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 30553 | |
| 30554 | expected_result = (unsigned long) (source1_ul - source2_u); |
| 30555 | |
| 30556 | result = proc(source1_ul, source2_u); |
| 30557 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 30558 | if (expected_result != result) { |
| 30559 | printf("Failed unsigned long - unsigned int test, expected %lu, got %lu, for %lu - %u\n", |
| 30560 | expected_result, result, source1_ul, source2_u); |
| 30561 | if (dumped == 0) cod_dump(gen_code); |
| 30562 | failed++; |
| 30563 | dumped++; |
| 30564 | } |
| 30565 | } |
| 30566 | } |
| 30567 | if (verbose) printf(" done\n"); |
| 30568 | cod_free_parse_context(context); |
| 30569 | cod_code_free(gen_code); |
| 30570 | } |
| 30571 | if ((only_run_test == NULL((void*)0)) || |
| 30572 | (strcmp(only_run_test, "ul-ul") == 0)) { |
| 30573 | int i, j; |
| 30574 | static char code[] = "{\n\ |
| 30575 | unsigned long a = p1;\n\ |
| 30576 | unsigned long b = p2;\n\ |
| 30577 | return a - b;\n\ |
| 30578 | }"; |
| 30579 | |
| 30580 | unsigned long (*proc)(unsigned long a, unsigned long b); |
| 30581 | cod_parse_context context = new_cod_parse_context(); |
| 30582 | int dumped = 0; |
| 30583 | |
| 30584 | cod_code gen_code; |
| 30585 | |
| 30586 | /* test for unsigned long - unsigned long */ |
| 30587 | if (verbose) printf("test for unsigned long - unsigned long"); |
| 30588 | |
| 30589 | cod_assoc_externs(context, externs); |
| 30590 | cod_parse_for_context(extern_string, context); |
| 30591 | |
| 30592 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, unsigned long p2)", |
| 30593 | context); |
| 30594 | gen_code = cod_code_gen(code, context); |
| 30595 | proc = (unsigned long (*)(unsigned long, unsigned long))(long)gen_code->func; |
| 30596 | |
| 30597 | |
| 30598 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 30599 | unsigned long source1_ul = src1ul_vals[i]; |
| 30600 | for (j=0 ; j < sizeof(src2ul_vals)/sizeof(src2ul_vals[0]) ; j++) { |
| 30601 | unsigned long source2_ul = src2ul_vals[j]; |
| 30602 | |
| 30603 | unsigned long expected_result; |
| 30604 | unsigned long result; |
| 30605 | |
| 30606 | |
| 30607 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 30608 | |
| 30609 | expected_result = (unsigned long) (source1_ul - source2_ul); |
| 30610 | |
| 30611 | result = proc(source1_ul, source2_ul); |
| 30612 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 30613 | if (expected_result != result) { |
| 30614 | printf("Failed unsigned long - unsigned long test, expected %lu, got %lu, for %lu - %lu\n", |
| 30615 | expected_result, result, source1_ul, source2_ul); |
| 30616 | if (dumped == 0) cod_dump(gen_code); |
| 30617 | failed++; |
| 30618 | dumped++; |
| 30619 | } |
| 30620 | } |
| 30621 | } |
| 30622 | if (verbose) printf(" done\n"); |
| 30623 | cod_free_parse_context(context); |
| 30624 | cod_code_free(gen_code); |
| 30625 | } |
| 30626 | if ((only_run_test == NULL((void*)0)) || |
| 30627 | (strcmp(only_run_test, "ul-l") == 0)) { |
| 30628 | int i, j; |
| 30629 | static char code[] = "{\n\ |
| 30630 | unsigned long a = p1;\n\ |
| 30631 | long b = p2;\n\ |
| 30632 | return a - b;\n\ |
| 30633 | }"; |
| 30634 | |
| 30635 | unsigned long (*proc)(unsigned long a, long b); |
| 30636 | cod_parse_context context = new_cod_parse_context(); |
| 30637 | int dumped = 0; |
| 30638 | |
| 30639 | cod_code gen_code; |
| 30640 | |
| 30641 | /* test for unsigned long - long */ |
| 30642 | if (verbose) printf("test for unsigned long - long"); |
| 30643 | |
| 30644 | cod_assoc_externs(context, externs); |
| 30645 | cod_parse_for_context(extern_string, context); |
| 30646 | |
| 30647 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, long p2)", |
| 30648 | context); |
| 30649 | gen_code = cod_code_gen(code, context); |
| 30650 | proc = (unsigned long (*)(unsigned long, long))(long)gen_code->func; |
| 30651 | |
| 30652 | |
| 30653 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 30654 | unsigned long source1_ul = src1ul_vals[i]; |
| 30655 | for (j=0 ; j < sizeof(src2l_vals)/sizeof(src2l_vals[0]) ; j++) { |
| 30656 | long source2_l = src2l_vals[j]; |
| 30657 | |
| 30658 | unsigned long expected_result; |
| 30659 | unsigned long result; |
| 30660 | |
| 30661 | |
| 30662 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 30663 | |
| 30664 | expected_result = (unsigned long) (source1_ul - source2_l); |
| 30665 | |
| 30666 | result = proc(source1_ul, source2_l); |
| 30667 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 30668 | if (expected_result != result) { |
| 30669 | printf("Failed unsigned long - long test, expected %lu, got %lu, for %lu - %ld\n", |
| 30670 | expected_result, result, source1_ul, source2_l); |
| 30671 | if (dumped == 0) cod_dump(gen_code); |
| 30672 | failed++; |
| 30673 | dumped++; |
| 30674 | } |
| 30675 | } |
| 30676 | } |
| 30677 | if (verbose) printf(" done\n"); |
| 30678 | cod_free_parse_context(context); |
| 30679 | cod_code_free(gen_code); |
| 30680 | } |
| 30681 | if ((only_run_test == NULL((void*)0)) || |
| 30682 | (strcmp(only_run_test, "ul-f") == 0)) { |
| 30683 | int i, j; |
| 30684 | static char code[] = "{\n\ |
| 30685 | unsigned long a = p1;\n\ |
| 30686 | float b = p2;\n\ |
| 30687 | return a - b;\n\ |
| 30688 | }"; |
| 30689 | |
| 30690 | unsigned long (*proc)(unsigned long a, float b); |
| 30691 | cod_parse_context context = new_cod_parse_context(); |
| 30692 | int dumped = 0; |
| 30693 | |
| 30694 | cod_code gen_code; |
| 30695 | |
| 30696 | /* test for unsigned long - float */ |
| 30697 | if (verbose) printf("test for unsigned long - float"); |
| 30698 | |
| 30699 | cod_assoc_externs(context, externs); |
| 30700 | cod_parse_for_context(extern_string, context); |
| 30701 | |
| 30702 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, float p2)", |
| 30703 | context); |
| 30704 | gen_code = cod_code_gen(code, context); |
| 30705 | proc = (unsigned long (*)(unsigned long, float))(long)gen_code->func; |
| 30706 | |
| 30707 | |
| 30708 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 30709 | unsigned long source1_ul = src1ul_vals[i]; |
| 30710 | for (j=0 ; j < sizeof(src2f_vals)/sizeof(src2f_vals[0]) ; j++) { |
| 30711 | float source2_f = src2f_vals[j]; |
| 30712 | double range = 0.000001 * (fabs((double)source1_ul) + fabs((double)source2_f)); |
| 30713 | unsigned long expected_result; |
| 30714 | unsigned long result; |
| 30715 | |
| 30716 | |
| 30717 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 30718 | |
| 30719 | expected_result = (unsigned long) (source1_ul - source2_f); |
| 30720 | |
| 30721 | result = proc(source1_ul, source2_f); |
| 30722 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 30723 | range += 1.0; |
| 30724 | if ((result > (expected_result + range)) || (result < (expected_result - range))) { |
| 30725 | printf("Failed unsigned long - float test, expected %lu, got %lu, for %lu - %g\n", |
| 30726 | expected_result, result, source1_ul, source2_f); |
| 30727 | if (dumped == 0) cod_dump(gen_code); |
| 30728 | failed++; |
| 30729 | dumped++; |
| 30730 | } |
| 30731 | } |
| 30732 | } |
| 30733 | if (verbose) printf(" done\n"); |
| 30734 | cod_free_parse_context(context); |
| 30735 | cod_code_free(gen_code); |
| 30736 | } |
| 30737 | if ((only_run_test == NULL((void*)0)) || |
| 30738 | (strcmp(only_run_test, "ul-d") == 0)) { |
| 30739 | int i, j; |
| 30740 | static char code[] = "{\n\ |
| 30741 | unsigned long a = p1;\n\ |
| 30742 | double b = p2;\n\ |
| 30743 | return a - b;\n\ |
| 30744 | }"; |
| 30745 | |
| 30746 | unsigned long (*proc)(unsigned long a, double b); |
| 30747 | cod_parse_context context = new_cod_parse_context(); |
| 30748 | int dumped = 0; |
| 30749 | |
| 30750 | cod_code gen_code; |
| 30751 | |
| 30752 | /* test for unsigned long - double */ |
| 30753 | if (verbose) printf("test for unsigned long - double"); |
| 30754 | |
| 30755 | cod_assoc_externs(context, externs); |
| 30756 | cod_parse_for_context(extern_string, context); |
| 30757 | |
| 30758 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, double p2)", |
| 30759 | context); |
| 30760 | gen_code = cod_code_gen(code, context); |
| 30761 | proc = (unsigned long (*)(unsigned long, double))(long)gen_code->func; |
| 30762 | |
| 30763 | |
| 30764 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 30765 | unsigned long source1_ul = src1ul_vals[i]; |
| 30766 | for (j=0 ; j < sizeof(src2d_vals)/sizeof(src2d_vals[0]) ; j++) { |
| 30767 | double source2_d = src2d_vals[j]; |
| 30768 | |
| 30769 | unsigned long expected_result; |
| 30770 | unsigned long result; |
| 30771 | |
| 30772 | |
| 30773 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 30774 | |
| 30775 | expected_result = (unsigned long) (source1_ul - source2_d); |
| 30776 | |
| 30777 | result = proc(source1_ul, source2_d); |
| 30778 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 30779 | if (expected_result != result) { |
| 30780 | printf("Failed unsigned long - double test, expected %lu, got %lu, for %lu - %g\n", |
| 30781 | expected_result, result, source1_ul, source2_d); |
| 30782 | if (dumped == 0) cod_dump(gen_code); |
| 30783 | failed++; |
| 30784 | dumped++; |
| 30785 | } |
| 30786 | } |
| 30787 | } |
| 30788 | if (verbose) printf(" done\n"); |
| 30789 | cod_free_parse_context(context); |
| 30790 | cod_code_free(gen_code); |
| 30791 | } |
| 30792 | } |
| 30793 | void sub_l_tests() |
| 30794 | { |
| 30795 | if ((only_run_test == NULL((void*)0)) || |
| 30796 | (strcmp(only_run_test, "l-c") == 0)) { |
| 30797 | int i, j; |
| 30798 | static char code[] = "{\n\ |
| 30799 | long a = p1;\n\ |
| 30800 | signed char b = p2;\n\ |
| 30801 | return a - b;\n\ |
| 30802 | }"; |
| 30803 | |
| 30804 | long (*proc)(long a, signed char b); |
| 30805 | cod_parse_context context = new_cod_parse_context(); |
| 30806 | int dumped = 0; |
| 30807 | |
| 30808 | cod_code gen_code; |
| 30809 | |
| 30810 | /* test for long - signed char */ |
| 30811 | if (verbose) printf("test for long - signed char"); |
| 30812 | |
| 30813 | cod_assoc_externs(context, externs); |
| 30814 | cod_parse_for_context(extern_string, context); |
| 30815 | |
| 30816 | cod_subroutine_declaration("long proc(long p1, signed char p2)", |
| 30817 | context); |
| 30818 | gen_code = cod_code_gen(code, context); |
| 30819 | proc = (long (*)(long, signed char))(long)gen_code->func; |
| 30820 | |
| 30821 | |
| 30822 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 30823 | long source1_l = src1l_vals[i]; |
| 30824 | for (j=0 ; j < sizeof(src2c_vals)/sizeof(src2c_vals[0]) ; j++) { |
| 30825 | signed char source2_c = src2c_vals[j]; |
| 30826 | |
| 30827 | long expected_result; |
| 30828 | long result; |
| 30829 | |
| 30830 | |
| 30831 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 30832 | |
| 30833 | expected_result = (long) (source1_l - source2_c); |
| 30834 | |
| 30835 | result = proc(source1_l, source2_c); |
| 30836 | if (expected_result != result) { |
| 30837 | printf("Failed long - signed char test, expected %ld, got %ld, for %ld - %d\n", |
| 30838 | expected_result, result, source1_l, source2_c); |
| 30839 | if (dumped == 0) cod_dump(gen_code); |
| 30840 | failed++; |
| 30841 | dumped++; |
| 30842 | } |
| 30843 | } |
| 30844 | } |
| 30845 | if (verbose) printf(" done\n"); |
| 30846 | cod_free_parse_context(context); |
| 30847 | cod_code_free(gen_code); |
| 30848 | } |
| 30849 | if ((only_run_test == NULL((void*)0)) || |
| 30850 | (strcmp(only_run_test, "l-uc") == 0)) { |
| 30851 | int i, j; |
| 30852 | static char code[] = "{\n\ |
| 30853 | long a = p1;\n\ |
| 30854 | unsigned char b = p2;\n\ |
| 30855 | return a - b;\n\ |
| 30856 | }"; |
| 30857 | |
| 30858 | long (*proc)(long a, unsigned char b); |
| 30859 | cod_parse_context context = new_cod_parse_context(); |
| 30860 | int dumped = 0; |
| 30861 | |
| 30862 | cod_code gen_code; |
| 30863 | |
| 30864 | /* test for long - unsigned char */ |
| 30865 | if (verbose) printf("test for long - unsigned char"); |
| 30866 | |
| 30867 | cod_assoc_externs(context, externs); |
| 30868 | cod_parse_for_context(extern_string, context); |
| 30869 | |
| 30870 | cod_subroutine_declaration("long proc(long p1, unsigned char p2)", |
| 30871 | context); |
| 30872 | gen_code = cod_code_gen(code, context); |
| 30873 | proc = (long (*)(long, unsigned char))(long)gen_code->func; |
| 30874 | |
| 30875 | |
| 30876 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 30877 | long source1_l = src1l_vals[i]; |
| 30878 | for (j=0 ; j < sizeof(src2uc_vals)/sizeof(src2uc_vals[0]) ; j++) { |
| 30879 | unsigned char source2_uc = src2uc_vals[j]; |
| 30880 | |
| 30881 | long expected_result; |
| 30882 | long result; |
| 30883 | |
| 30884 | |
| 30885 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 30886 | |
| 30887 | expected_result = (long) (source1_l - source2_uc); |
| 30888 | |
| 30889 | result = proc(source1_l, source2_uc); |
| 30890 | if (expected_result != result) { |
| 30891 | printf("Failed long - unsigned char test, expected %ld, got %ld, for %ld - %u\n", |
| 30892 | expected_result, result, source1_l, source2_uc); |
| 30893 | if (dumped == 0) cod_dump(gen_code); |
| 30894 | failed++; |
| 30895 | dumped++; |
| 30896 | } |
| 30897 | } |
| 30898 | } |
| 30899 | if (verbose) printf(" done\n"); |
| 30900 | cod_free_parse_context(context); |
| 30901 | cod_code_free(gen_code); |
| 30902 | } |
| 30903 | if ((only_run_test == NULL((void*)0)) || |
| 30904 | (strcmp(only_run_test, "l-s") == 0)) { |
| 30905 | int i, j; |
| 30906 | static char code[] = "{\n\ |
| 30907 | long a = p1;\n\ |
| 30908 | short b = p2;\n\ |
| 30909 | return a - b;\n\ |
| 30910 | }"; |
| 30911 | |
| 30912 | long (*proc)(long a, short b); |
| 30913 | cod_parse_context context = new_cod_parse_context(); |
| 30914 | int dumped = 0; |
| 30915 | |
| 30916 | cod_code gen_code; |
| 30917 | |
| 30918 | /* test for long - short */ |
| 30919 | if (verbose) printf("test for long - short"); |
| 30920 | |
| 30921 | cod_assoc_externs(context, externs); |
| 30922 | cod_parse_for_context(extern_string, context); |
| 30923 | |
| 30924 | cod_subroutine_declaration("long proc(long p1, short p2)", |
| 30925 | context); |
| 30926 | gen_code = cod_code_gen(code, context); |
| 30927 | proc = (long (*)(long, short))(long)gen_code->func; |
| 30928 | |
| 30929 | |
| 30930 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 30931 | long source1_l = src1l_vals[i]; |
| 30932 | for (j=0 ; j < sizeof(src2s_vals)/sizeof(src2s_vals[0]) ; j++) { |
| 30933 | short source2_s = src2s_vals[j]; |
| 30934 | |
| 30935 | long expected_result; |
| 30936 | long result; |
| 30937 | |
| 30938 | |
| 30939 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 30940 | |
| 30941 | expected_result = (long) (source1_l - source2_s); |
| 30942 | |
| 30943 | result = proc(source1_l, source2_s); |
| 30944 | if (expected_result != result) { |
| 30945 | printf("Failed long - short test, expected %ld, got %ld, for %ld - %d\n", |
| 30946 | expected_result, result, source1_l, source2_s); |
| 30947 | if (dumped == 0) cod_dump(gen_code); |
| 30948 | failed++; |
| 30949 | dumped++; |
| 30950 | } |
| 30951 | } |
| 30952 | } |
| 30953 | if (verbose) printf(" done\n"); |
| 30954 | cod_free_parse_context(context); |
| 30955 | cod_code_free(gen_code); |
| 30956 | } |
| 30957 | if ((only_run_test == NULL((void*)0)) || |
| 30958 | (strcmp(only_run_test, "l-us") == 0)) { |
| 30959 | int i, j; |
| 30960 | static char code[] = "{\n\ |
| 30961 | long a = p1;\n\ |
| 30962 | unsigned short b = p2;\n\ |
| 30963 | return a - b;\n\ |
| 30964 | }"; |
| 30965 | |
| 30966 | long (*proc)(long a, unsigned short b); |
| 30967 | cod_parse_context context = new_cod_parse_context(); |
| 30968 | int dumped = 0; |
| 30969 | |
| 30970 | cod_code gen_code; |
| 30971 | |
| 30972 | /* test for long - unsigned short */ |
| 30973 | if (verbose) printf("test for long - unsigned short"); |
| 30974 | |
| 30975 | cod_assoc_externs(context, externs); |
| 30976 | cod_parse_for_context(extern_string, context); |
| 30977 | |
| 30978 | cod_subroutine_declaration("long proc(long p1, unsigned short p2)", |
| 30979 | context); |
| 30980 | gen_code = cod_code_gen(code, context); |
| 30981 | proc = (long (*)(long, unsigned short))(long)gen_code->func; |
| 30982 | |
| 30983 | |
| 30984 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 30985 | long source1_l = src1l_vals[i]; |
| 30986 | for (j=0 ; j < sizeof(src2us_vals)/sizeof(src2us_vals[0]) ; j++) { |
| 30987 | unsigned short source2_us = src2us_vals[j]; |
| 30988 | |
| 30989 | long expected_result; |
| 30990 | long result; |
| 30991 | |
| 30992 | |
| 30993 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 30994 | |
| 30995 | expected_result = (long) (source1_l - source2_us); |
| 30996 | |
| 30997 | result = proc(source1_l, source2_us); |
| 30998 | if (expected_result != result) { |
| 30999 | printf("Failed long - unsigned short test, expected %ld, got %ld, for %ld - %u\n", |
| 31000 | expected_result, result, source1_l, source2_us); |
| 31001 | if (dumped == 0) cod_dump(gen_code); |
| 31002 | failed++; |
| 31003 | dumped++; |
| 31004 | } |
| 31005 | } |
| 31006 | } |
| 31007 | if (verbose) printf(" done\n"); |
| 31008 | cod_free_parse_context(context); |
| 31009 | cod_code_free(gen_code); |
| 31010 | } |
| 31011 | if ((only_run_test == NULL((void*)0)) || |
| 31012 | (strcmp(only_run_test, "l-i") == 0)) { |
| 31013 | int i, j; |
| 31014 | static char code[] = "{\n\ |
| 31015 | long a = p1;\n\ |
| 31016 | int b = p2;\n\ |
| 31017 | return a - b;\n\ |
| 31018 | }"; |
| 31019 | |
| 31020 | long (*proc)(long a, int b); |
| 31021 | cod_parse_context context = new_cod_parse_context(); |
| 31022 | int dumped = 0; |
| 31023 | |
| 31024 | cod_code gen_code; |
| 31025 | |
| 31026 | /* test for long - int */ |
| 31027 | if (verbose) printf("test for long - int"); |
| 31028 | |
| 31029 | cod_assoc_externs(context, externs); |
| 31030 | cod_parse_for_context(extern_string, context); |
| 31031 | |
| 31032 | cod_subroutine_declaration("long proc(long p1, int p2)", |
| 31033 | context); |
| 31034 | gen_code = cod_code_gen(code, context); |
| 31035 | proc = (long (*)(long, int))(long)gen_code->func; |
| 31036 | |
| 31037 | |
| 31038 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 31039 | long source1_l = src1l_vals[i]; |
| 31040 | for (j=0 ; j < sizeof(src2i_vals)/sizeof(src2i_vals[0]) ; j++) { |
| 31041 | int source2_i = src2i_vals[j]; |
| 31042 | |
| 31043 | long expected_result; |
| 31044 | long result; |
| 31045 | |
| 31046 | |
| 31047 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 31048 | |
| 31049 | expected_result = (long) (source1_l - source2_i); |
| 31050 | |
| 31051 | result = proc(source1_l, source2_i); |
| 31052 | if (expected_result != result) { |
| 31053 | printf("Failed long - int test, expected %ld, got %ld, for %ld - %d\n", |
| 31054 | expected_result, result, source1_l, source2_i); |
| 31055 | if (dumped == 0) cod_dump(gen_code); |
| 31056 | failed++; |
| 31057 | dumped++; |
| 31058 | } |
| 31059 | } |
| 31060 | } |
| 31061 | if (verbose) printf(" done\n"); |
| 31062 | cod_free_parse_context(context); |
| 31063 | cod_code_free(gen_code); |
| 31064 | } |
| 31065 | if ((only_run_test == NULL((void*)0)) || |
| 31066 | (strcmp(only_run_test, "l-u") == 0)) { |
| 31067 | int i, j; |
| 31068 | static char code[] = "{\n\ |
| 31069 | long a = p1;\n\ |
| 31070 | unsigned int b = p2;\n\ |
| 31071 | return a - b;\n\ |
| 31072 | }"; |
| 31073 | |
| 31074 | long (*proc)(long a, unsigned int b); |
| 31075 | cod_parse_context context = new_cod_parse_context(); |
| 31076 | int dumped = 0; |
| 31077 | |
| 31078 | cod_code gen_code; |
| 31079 | |
| 31080 | /* test for long - unsigned int */ |
| 31081 | if (verbose) printf("test for long - unsigned int"); |
| 31082 | |
| 31083 | cod_assoc_externs(context, externs); |
| 31084 | cod_parse_for_context(extern_string, context); |
| 31085 | |
| 31086 | cod_subroutine_declaration("long proc(long p1, unsigned int p2)", |
| 31087 | context); |
| 31088 | gen_code = cod_code_gen(code, context); |
| 31089 | proc = (long (*)(long, unsigned int))(long)gen_code->func; |
| 31090 | |
| 31091 | |
| 31092 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 31093 | long source1_l = src1l_vals[i]; |
| 31094 | for (j=0 ; j < sizeof(src2u_vals)/sizeof(src2u_vals[0]) ; j++) { |
| 31095 | unsigned int source2_u = src2u_vals[j]; |
| 31096 | |
| 31097 | long expected_result; |
| 31098 | long result; |
| 31099 | |
| 31100 | |
| 31101 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 31102 | |
| 31103 | expected_result = (long) (source1_l - source2_u); |
| 31104 | |
| 31105 | result = proc(source1_l, source2_u); |
| 31106 | if (expected_result != result) { |
| 31107 | printf("Failed long - unsigned int test, expected %ld, got %ld, for %ld - %u\n", |
| 31108 | expected_result, result, source1_l, source2_u); |
| 31109 | if (dumped == 0) cod_dump(gen_code); |
| 31110 | failed++; |
| 31111 | dumped++; |
| 31112 | } |
| 31113 | } |
| 31114 | } |
| 31115 | if (verbose) printf(" done\n"); |
| 31116 | cod_free_parse_context(context); |
| 31117 | cod_code_free(gen_code); |
| 31118 | } |
| 31119 | if ((only_run_test == NULL((void*)0)) || |
| 31120 | (strcmp(only_run_test, "l-ul") == 0)) { |
| 31121 | int i, j; |
| 31122 | static char code[] = "{\n\ |
| 31123 | long a = p1;\n\ |
| 31124 | unsigned long b = p2;\n\ |
| 31125 | return a - b;\n\ |
| 31126 | }"; |
| 31127 | |
| 31128 | long (*proc)(long a, unsigned long b); |
| 31129 | cod_parse_context context = new_cod_parse_context(); |
| 31130 | int dumped = 0; |
| 31131 | |
| 31132 | cod_code gen_code; |
| 31133 | |
| 31134 | /* test for long - unsigned long */ |
| 31135 | if (verbose) printf("test for long - unsigned long"); |
| 31136 | |
| 31137 | cod_assoc_externs(context, externs); |
| 31138 | cod_parse_for_context(extern_string, context); |
| 31139 | |
| 31140 | cod_subroutine_declaration("long proc(long p1, unsigned long p2)", |
| 31141 | context); |
| 31142 | gen_code = cod_code_gen(code, context); |
| 31143 | proc = (long (*)(long, unsigned long))(long)gen_code->func; |
| 31144 | |
| 31145 | |
| 31146 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 31147 | long source1_l = src1l_vals[i]; |
| 31148 | for (j=0 ; j < sizeof(src2ul_vals)/sizeof(src2ul_vals[0]) ; j++) { |
| 31149 | unsigned long source2_ul = src2ul_vals[j]; |
| 31150 | |
| 31151 | long expected_result; |
| 31152 | long result; |
| 31153 | |
| 31154 | |
| 31155 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 31156 | |
| 31157 | expected_result = (long) (source1_l - source2_ul); |
| 31158 | |
| 31159 | result = proc(source1_l, source2_ul); |
| 31160 | if (expected_result != result) { |
| 31161 | printf("Failed long - unsigned long test, expected %ld, got %ld, for %ld - %lu\n", |
| 31162 | expected_result, result, source1_l, source2_ul); |
| 31163 | if (dumped == 0) cod_dump(gen_code); |
| 31164 | failed++; |
| 31165 | dumped++; |
| 31166 | } |
| 31167 | } |
| 31168 | } |
| 31169 | if (verbose) printf(" done\n"); |
| 31170 | cod_free_parse_context(context); |
| 31171 | cod_code_free(gen_code); |
| 31172 | } |
| 31173 | if ((only_run_test == NULL((void*)0)) || |
| 31174 | (strcmp(only_run_test, "l-l") == 0)) { |
| 31175 | int i, j; |
| 31176 | static char code[] = "{\n\ |
| 31177 | long a = p1;\n\ |
| 31178 | long b = p2;\n\ |
| 31179 | return a - b;\n\ |
| 31180 | }"; |
| 31181 | |
| 31182 | long (*proc)(long a, long b); |
| 31183 | cod_parse_context context = new_cod_parse_context(); |
| 31184 | int dumped = 0; |
| 31185 | |
| 31186 | cod_code gen_code; |
| 31187 | |
| 31188 | /* test for long - long */ |
| 31189 | if (verbose) printf("test for long - long"); |
| 31190 | |
| 31191 | cod_assoc_externs(context, externs); |
| 31192 | cod_parse_for_context(extern_string, context); |
| 31193 | |
| 31194 | cod_subroutine_declaration("long proc(long p1, long p2)", |
| 31195 | context); |
| 31196 | gen_code = cod_code_gen(code, context); |
| 31197 | proc = (long (*)(long, long))(long)gen_code->func; |
| 31198 | |
| 31199 | |
| 31200 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 31201 | long source1_l = src1l_vals[i]; |
| 31202 | for (j=0 ; j < sizeof(src2l_vals)/sizeof(src2l_vals[0]) ; j++) { |
| 31203 | long source2_l = src2l_vals[j]; |
| 31204 | |
| 31205 | long expected_result; |
| 31206 | long result; |
| 31207 | |
| 31208 | |
| 31209 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 31210 | |
| 31211 | expected_result = (long) (source1_l - source2_l); |
| 31212 | |
| 31213 | result = proc(source1_l, source2_l); |
| 31214 | if (expected_result != result) { |
| 31215 | printf("Failed long - long test, expected %ld, got %ld, for %ld - %ld\n", |
| 31216 | expected_result, result, source1_l, source2_l); |
| 31217 | if (dumped == 0) cod_dump(gen_code); |
| 31218 | failed++; |
| 31219 | dumped++; |
| 31220 | } |
| 31221 | } |
| 31222 | } |
| 31223 | if (verbose) printf(" done\n"); |
| 31224 | cod_free_parse_context(context); |
| 31225 | cod_code_free(gen_code); |
| 31226 | } |
| 31227 | if ((only_run_test == NULL((void*)0)) || |
| 31228 | (strcmp(only_run_test, "l-f") == 0)) { |
| 31229 | int i, j; |
| 31230 | static char code[] = "{\n\ |
| 31231 | long a = p1;\n\ |
| 31232 | float b = p2;\n\ |
| 31233 | return a - b;\n\ |
| 31234 | }"; |
| 31235 | |
| 31236 | long (*proc)(long a, float b); |
| 31237 | cod_parse_context context = new_cod_parse_context(); |
| 31238 | int dumped = 0; |
| 31239 | |
| 31240 | cod_code gen_code; |
| 31241 | |
| 31242 | /* test for long - float */ |
| 31243 | if (verbose) printf("test for long - float"); |
| 31244 | |
| 31245 | cod_assoc_externs(context, externs); |
| 31246 | cod_parse_for_context(extern_string, context); |
| 31247 | |
| 31248 | cod_subroutine_declaration("long proc(long p1, float p2)", |
| 31249 | context); |
| 31250 | gen_code = cod_code_gen(code, context); |
| 31251 | proc = (long (*)(long, float))(long)gen_code->func; |
| 31252 | |
| 31253 | |
| 31254 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 31255 | long source1_l = src1l_vals[i]; |
| 31256 | for (j=0 ; j < sizeof(src2f_vals)/sizeof(src2f_vals[0]) ; j++) { |
| 31257 | float source2_f = src2f_vals[j]; |
| 31258 | double range = 0.000001 * (fabs((double)source1_l) + fabs((double)source2_f)); |
| 31259 | long expected_result; |
| 31260 | long result; |
| 31261 | |
| 31262 | |
| 31263 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 31264 | |
| 31265 | expected_result = (long) (source1_l - source2_f); |
| 31266 | |
| 31267 | result = proc(source1_l, source2_f); |
| 31268 | range += 1.0; |
| 31269 | if ((result > (expected_result + range)) || (result < (expected_result - range))) { |
| 31270 | printf("Failed long - float test, expected %ld, got %ld, for %ld - %g\n", |
| 31271 | expected_result, result, source1_l, source2_f); |
| 31272 | if (dumped == 0) cod_dump(gen_code); |
| 31273 | failed++; |
| 31274 | dumped++; |
| 31275 | } |
| 31276 | } |
| 31277 | } |
| 31278 | if (verbose) printf(" done\n"); |
| 31279 | cod_free_parse_context(context); |
| 31280 | cod_code_free(gen_code); |
| 31281 | } |
| 31282 | if ((only_run_test == NULL((void*)0)) || |
| 31283 | (strcmp(only_run_test, "l-d") == 0)) { |
| 31284 | int i, j; |
| 31285 | static char code[] = "{\n\ |
| 31286 | long a = p1;\n\ |
| 31287 | double b = p2;\n\ |
| 31288 | return a - b;\n\ |
| 31289 | }"; |
| 31290 | |
| 31291 | long (*proc)(long a, double b); |
| 31292 | cod_parse_context context = new_cod_parse_context(); |
| 31293 | int dumped = 0; |
| 31294 | |
| 31295 | cod_code gen_code; |
| 31296 | |
| 31297 | /* test for long - double */ |
| 31298 | if (verbose) printf("test for long - double"); |
| 31299 | |
| 31300 | cod_assoc_externs(context, externs); |
| 31301 | cod_parse_for_context(extern_string, context); |
| 31302 | |
| 31303 | cod_subroutine_declaration("long proc(long p1, double p2)", |
| 31304 | context); |
| 31305 | gen_code = cod_code_gen(code, context); |
| 31306 | proc = (long (*)(long, double))(long)gen_code->func; |
| 31307 | |
| 31308 | |
| 31309 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 31310 | long source1_l = src1l_vals[i]; |
| 31311 | for (j=0 ; j < sizeof(src2d_vals)/sizeof(src2d_vals[0]) ; j++) { |
| 31312 | double source2_d = src2d_vals[j]; |
| 31313 | |
| 31314 | long expected_result; |
| 31315 | long result; |
| 31316 | |
| 31317 | |
| 31318 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 31319 | |
| 31320 | expected_result = (long) (source1_l - source2_d); |
| 31321 | |
| 31322 | result = proc(source1_l, source2_d); |
| 31323 | if (expected_result != result) { |
| 31324 | printf("Failed long - double test, expected %ld, got %ld, for %ld - %g\n", |
| 31325 | expected_result, result, source1_l, source2_d); |
| 31326 | if (dumped == 0) cod_dump(gen_code); |
| 31327 | failed++; |
| 31328 | dumped++; |
| 31329 | } |
| 31330 | } |
| 31331 | } |
| 31332 | if (verbose) printf(" done\n"); |
| 31333 | cod_free_parse_context(context); |
| 31334 | cod_code_free(gen_code); |
| 31335 | } |
| 31336 | } |
| 31337 | void sub_f_tests() |
| 31338 | { |
| 31339 | if ((only_run_test == NULL((void*)0)) || |
| 31340 | (strcmp(only_run_test, "f-c") == 0)) { |
| 31341 | int i, j; |
| 31342 | static char code[] = "{\n\ |
| 31343 | float a = p1;\n\ |
| 31344 | signed char b = p2;\n\ |
| 31345 | return a - b;\n\ |
| 31346 | }"; |
| 31347 | |
| 31348 | float (*proc)(float a, signed char b); |
| 31349 | cod_parse_context context = new_cod_parse_context(); |
| 31350 | int dumped = 0; |
| 31351 | |
| 31352 | cod_code gen_code; |
| 31353 | |
| 31354 | /* test for float - signed char */ |
| 31355 | if (verbose) printf("test for float - signed char"); |
| 31356 | |
| 31357 | cod_assoc_externs(context, externs); |
| 31358 | cod_parse_for_context(extern_string, context); |
| 31359 | |
| 31360 | cod_subroutine_declaration("float proc(float p1, signed char p2)", |
| 31361 | context); |
| 31362 | gen_code = cod_code_gen(code, context); |
| 31363 | proc = (float (*)(float, signed char))(long)gen_code->func; |
| 31364 | |
| 31365 | |
| 31366 | for (i=0 ; i < sizeof(src1f_vals)/sizeof(src1f_vals[0]) ; i++) { |
| 31367 | float source1_f = src1f_vals[i]; |
| 31368 | for (j=0 ; j < sizeof(src2c_vals)/sizeof(src2c_vals[0]) ; j++) { |
| 31369 | signed char source2_c = src2c_vals[j]; |
| 31370 | double range = 0.000001 * (fabs((double)source1_f) + fabs((double)source2_c)); |
| 31371 | float expected_result; |
| 31372 | float result; |
| 31373 | |
| 31374 | |
| 31375 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 31376 | |
| 31377 | expected_result = (float) (source1_f - source2_c); |
| 31378 | |
| 31379 | result = proc(source1_f, source2_c); |
| 31380 | range += 1.0; |
| 31381 | if ((result > (expected_result + range)) || (result < (expected_result - range))) { |
| 31382 | printf("Failed float - signed char test, expected %g, got %g, for %g - %d\n", |
| 31383 | expected_result, result, source1_f, source2_c); |
| 31384 | if (dumped == 0) cod_dump(gen_code); |
| 31385 | failed++; |
| 31386 | dumped++; |
| 31387 | } |
| 31388 | } |
| 31389 | } |
| 31390 | if (verbose) printf(" done\n"); |
| 31391 | cod_free_parse_context(context); |
| 31392 | cod_code_free(gen_code); |
| 31393 | } |
| 31394 | if ((only_run_test == NULL((void*)0)) || |
| 31395 | (strcmp(only_run_test, "f-uc") == 0)) { |
| 31396 | int i, j; |
| 31397 | static char code[] = "{\n\ |
| 31398 | float a = p1;\n\ |
| 31399 | unsigned char b = p2;\n\ |
| 31400 | return a - b;\n\ |
| 31401 | }"; |
| 31402 | |
| 31403 | float (*proc)(float a, unsigned char b); |
| 31404 | cod_parse_context context = new_cod_parse_context(); |
| 31405 | int dumped = 0; |
| 31406 | |
| 31407 | cod_code gen_code; |
| 31408 | |
| 31409 | /* test for float - unsigned char */ |
| 31410 | if (verbose) printf("test for float - unsigned char"); |
| 31411 | |
| 31412 | cod_assoc_externs(context, externs); |
| 31413 | cod_parse_for_context(extern_string, context); |
| 31414 | |
| 31415 | cod_subroutine_declaration("float proc(float p1, unsigned char p2)", |
| 31416 | context); |
| 31417 | gen_code = cod_code_gen(code, context); |
| 31418 | proc = (float (*)(float, unsigned char))(long)gen_code->func; |
| 31419 | |
| 31420 | |
| 31421 | for (i=0 ; i < sizeof(src1f_vals)/sizeof(src1f_vals[0]) ; i++) { |
| 31422 | float source1_f = src1f_vals[i]; |
| 31423 | for (j=0 ; j < sizeof(src2uc_vals)/sizeof(src2uc_vals[0]) ; j++) { |
| 31424 | unsigned char source2_uc = src2uc_vals[j]; |
| 31425 | double range = 0.000001 * (fabs((double)source1_f) + fabs((double)source2_uc)); |
| 31426 | float expected_result; |
| 31427 | float result; |
| 31428 | |
| 31429 | |
| 31430 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 31431 | |
| 31432 | expected_result = (float) (source1_f - source2_uc); |
| 31433 | |
| 31434 | result = proc(source1_f, source2_uc); |
| 31435 | range += 1.0; |
| 31436 | if ((result > (expected_result + range)) || (result < (expected_result - range))) { |
| 31437 | printf("Failed float - unsigned char test, expected %g, got %g, for %g - %u\n", |
| 31438 | expected_result, result, source1_f, source2_uc); |
| 31439 | if (dumped == 0) cod_dump(gen_code); |
| 31440 | failed++; |
| 31441 | dumped++; |
| 31442 | } |
| 31443 | } |
| 31444 | } |
| 31445 | if (verbose) printf(" done\n"); |
| 31446 | cod_free_parse_context(context); |
| 31447 | cod_code_free(gen_code); |
| 31448 | } |
| 31449 | if ((only_run_test == NULL((void*)0)) || |
| 31450 | (strcmp(only_run_test, "f-s") == 0)) { |
| 31451 | int i, j; |
| 31452 | static char code[] = "{\n\ |
| 31453 | float a = p1;\n\ |
| 31454 | short b = p2;\n\ |
| 31455 | return a - b;\n\ |
| 31456 | }"; |
| 31457 | |
| 31458 | float (*proc)(float a, short b); |
| 31459 | cod_parse_context context = new_cod_parse_context(); |
| 31460 | int dumped = 0; |
| 31461 | |
| 31462 | cod_code gen_code; |
| 31463 | |
| 31464 | /* test for float - short */ |
| 31465 | if (verbose) printf("test for float - short"); |
| 31466 | |
| 31467 | cod_assoc_externs(context, externs); |
| 31468 | cod_parse_for_context(extern_string, context); |
| 31469 | |
| 31470 | cod_subroutine_declaration("float proc(float p1, short p2)", |
| 31471 | context); |
| 31472 | gen_code = cod_code_gen(code, context); |
| 31473 | proc = (float (*)(float, short))(long)gen_code->func; |
| 31474 | |
| 31475 | |
| 31476 | for (i=0 ; i < sizeof(src1f_vals)/sizeof(src1f_vals[0]) ; i++) { |
| 31477 | float source1_f = src1f_vals[i]; |
| 31478 | for (j=0 ; j < sizeof(src2s_vals)/sizeof(src2s_vals[0]) ; j++) { |
| 31479 | short source2_s = src2s_vals[j]; |
| 31480 | double range = 0.000001 * (fabs((double)source1_f) + fabs((double)source2_s)); |
| 31481 | float expected_result; |
| 31482 | float result; |
| 31483 | |
| 31484 | |
| 31485 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 31486 | |
| 31487 | expected_result = (float) (source1_f - source2_s); |
| 31488 | |
| 31489 | result = proc(source1_f, source2_s); |
| 31490 | range += 1.0; |
| 31491 | if ((result > (expected_result + range)) || (result < (expected_result - range))) { |
| 31492 | printf("Failed float - short test, expected %g, got %g, for %g - %d\n", |
| 31493 | expected_result, result, source1_f, source2_s); |
| 31494 | if (dumped == 0) cod_dump(gen_code); |
| 31495 | failed++; |
| 31496 | dumped++; |
| 31497 | } |
| 31498 | } |
| 31499 | } |
| 31500 | if (verbose) printf(" done\n"); |
| 31501 | cod_free_parse_context(context); |
| 31502 | cod_code_free(gen_code); |
| 31503 | } |
| 31504 | if ((only_run_test == NULL((void*)0)) || |
| 31505 | (strcmp(only_run_test, "f-us") == 0)) { |
| 31506 | int i, j; |
| 31507 | static char code[] = "{\n\ |
| 31508 | float a = p1;\n\ |
| 31509 | unsigned short b = p2;\n\ |
| 31510 | return a - b;\n\ |
| 31511 | }"; |
| 31512 | |
| 31513 | float (*proc)(float a, unsigned short b); |
| 31514 | cod_parse_context context = new_cod_parse_context(); |
| 31515 | int dumped = 0; |
| 31516 | |
| 31517 | cod_code gen_code; |
| 31518 | |
| 31519 | /* test for float - unsigned short */ |
| 31520 | if (verbose) printf("test for float - unsigned short"); |
| 31521 | |
| 31522 | cod_assoc_externs(context, externs); |
| 31523 | cod_parse_for_context(extern_string, context); |
| 31524 | |
| 31525 | cod_subroutine_declaration("float proc(float p1, unsigned short p2)", |
| 31526 | context); |
| 31527 | gen_code = cod_code_gen(code, context); |
| 31528 | proc = (float (*)(float, unsigned short))(long)gen_code->func; |
| 31529 | |
| 31530 | |
| 31531 | for (i=0 ; i < sizeof(src1f_vals)/sizeof(src1f_vals[0]) ; i++) { |
| 31532 | float source1_f = src1f_vals[i]; |
| 31533 | for (j=0 ; j < sizeof(src2us_vals)/sizeof(src2us_vals[0]) ; j++) { |
| 31534 | unsigned short source2_us = src2us_vals[j]; |
| 31535 | double range = 0.000001 * (fabs((double)source1_f) + fabs((double)source2_us)); |
| 31536 | float expected_result; |
| 31537 | float result; |
| 31538 | |
| 31539 | |
| 31540 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 31541 | |
| 31542 | expected_result = (float) (source1_f - source2_us); |
| 31543 | |
| 31544 | result = proc(source1_f, source2_us); |
| 31545 | range += 1.0; |
| 31546 | if ((result > (expected_result + range)) || (result < (expected_result - range))) { |
| 31547 | printf("Failed float - unsigned short test, expected %g, got %g, for %g - %u\n", |
| 31548 | expected_result, result, source1_f, source2_us); |
| 31549 | if (dumped == 0) cod_dump(gen_code); |
| 31550 | failed++; |
| 31551 | dumped++; |
| 31552 | } |
| 31553 | } |
| 31554 | } |
| 31555 | if (verbose) printf(" done\n"); |
| 31556 | cod_free_parse_context(context); |
| 31557 | cod_code_free(gen_code); |
| 31558 | } |
| 31559 | if ((only_run_test == NULL((void*)0)) || |
| 31560 | (strcmp(only_run_test, "f-i") == 0)) { |
| 31561 | int i, j; |
| 31562 | static char code[] = "{\n\ |
| 31563 | float a = p1;\n\ |
| 31564 | int b = p2;\n\ |
| 31565 | return a - b;\n\ |
| 31566 | }"; |
| 31567 | |
| 31568 | float (*proc)(float a, int b); |
| 31569 | cod_parse_context context = new_cod_parse_context(); |
| 31570 | int dumped = 0; |
| 31571 | |
| 31572 | cod_code gen_code; |
| 31573 | |
| 31574 | /* test for float - int */ |
| 31575 | if (verbose) printf("test for float - int"); |
| 31576 | |
| 31577 | cod_assoc_externs(context, externs); |
| 31578 | cod_parse_for_context(extern_string, context); |
| 31579 | |
| 31580 | cod_subroutine_declaration("float proc(float p1, int p2)", |
| 31581 | context); |
| 31582 | gen_code = cod_code_gen(code, context); |
| 31583 | proc = (float (*)(float, int))(long)gen_code->func; |
| 31584 | |
| 31585 | |
| 31586 | for (i=0 ; i < sizeof(src1f_vals)/sizeof(src1f_vals[0]) ; i++) { |
| 31587 | float source1_f = src1f_vals[i]; |
| 31588 | for (j=0 ; j < sizeof(src2i_vals)/sizeof(src2i_vals[0]) ; j++) { |
| 31589 | int source2_i = src2i_vals[j]; |
| 31590 | double range = 0.000001 * (fabs((double)source1_f) + fabs((double)source2_i)); |
| 31591 | float expected_result; |
| 31592 | float result; |
| 31593 | |
| 31594 | |
| 31595 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 31596 | |
| 31597 | expected_result = (float) (source1_f - source2_i); |
| 31598 | |
| 31599 | result = proc(source1_f, source2_i); |
| 31600 | range += 1.0; |
| 31601 | if ((result > (expected_result + range)) || (result < (expected_result - range))) { |
| 31602 | printf("Failed float - int test, expected %g, got %g, for %g - %d\n", |
| 31603 | expected_result, result, source1_f, source2_i); |
| 31604 | if (dumped == 0) cod_dump(gen_code); |
| 31605 | failed++; |
| 31606 | dumped++; |
| 31607 | } |
| 31608 | } |
| 31609 | } |
| 31610 | if (verbose) printf(" done\n"); |
| 31611 | cod_free_parse_context(context); |
| 31612 | cod_code_free(gen_code); |
| 31613 | } |
| 31614 | if ((only_run_test == NULL((void*)0)) || |
| 31615 | (strcmp(only_run_test, "f-u") == 0)) { |
| 31616 | int i, j; |
| 31617 | static char code[] = "{\n\ |
| 31618 | float a = p1;\n\ |
| 31619 | unsigned int b = p2;\n\ |
| 31620 | return a - b;\n\ |
| 31621 | }"; |
| 31622 | |
| 31623 | float (*proc)(float a, unsigned int b); |
| 31624 | cod_parse_context context = new_cod_parse_context(); |
| 31625 | int dumped = 0; |
| 31626 | |
| 31627 | cod_code gen_code; |
| 31628 | |
| 31629 | /* test for float - unsigned int */ |
| 31630 | if (verbose) printf("test for float - unsigned int"); |
| 31631 | |
| 31632 | cod_assoc_externs(context, externs); |
| 31633 | cod_parse_for_context(extern_string, context); |
| 31634 | |
| 31635 | cod_subroutine_declaration("float proc(float p1, unsigned int p2)", |
| 31636 | context); |
| 31637 | gen_code = cod_code_gen(code, context); |
| 31638 | proc = (float (*)(float, unsigned int))(long)gen_code->func; |
| 31639 | |
| 31640 | |
| 31641 | for (i=0 ; i < sizeof(src1f_vals)/sizeof(src1f_vals[0]) ; i++) { |
| 31642 | float source1_f = src1f_vals[i]; |
| 31643 | for (j=0 ; j < sizeof(src2u_vals)/sizeof(src2u_vals[0]) ; j++) { |
| 31644 | unsigned int source2_u = src2u_vals[j]; |
| 31645 | double range = 0.000001 * (fabs((double)source1_f) + fabs((double)source2_u)); |
| 31646 | float expected_result; |
| 31647 | float result; |
| 31648 | |
| 31649 | |
| 31650 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 31651 | |
| 31652 | expected_result = (float) (source1_f - source2_u); |
| 31653 | |
| 31654 | result = proc(source1_f, source2_u); |
| 31655 | range += 1.0; |
| 31656 | if ((result > (expected_result + range)) || (result < (expected_result - range))) { |
| 31657 | printf("Failed float - unsigned int test, expected %g, got %g, for %g - %u\n", |
| 31658 | expected_result, result, source1_f, source2_u); |
| 31659 | if (dumped == 0) cod_dump(gen_code); |
| 31660 | failed++; |
| 31661 | dumped++; |
| 31662 | } |
| 31663 | } |
| 31664 | } |
| 31665 | if (verbose) printf(" done\n"); |
| 31666 | cod_free_parse_context(context); |
| 31667 | cod_code_free(gen_code); |
| 31668 | } |
| 31669 | if ((only_run_test == NULL((void*)0)) || |
| 31670 | (strcmp(only_run_test, "f-ul") == 0)) { |
| 31671 | int i, j; |
| 31672 | static char code[] = "{\n\ |
| 31673 | float a = p1;\n\ |
| 31674 | unsigned long b = p2;\n\ |
| 31675 | return a - b;\n\ |
| 31676 | }"; |
| 31677 | |
| 31678 | float (*proc)(float a, unsigned long b); |
| 31679 | cod_parse_context context = new_cod_parse_context(); |
| 31680 | int dumped = 0; |
| 31681 | |
| 31682 | cod_code gen_code; |
| 31683 | |
| 31684 | /* test for float - unsigned long */ |
| 31685 | if (verbose) printf("test for float - unsigned long"); |
| 31686 | |
| 31687 | cod_assoc_externs(context, externs); |
| 31688 | cod_parse_for_context(extern_string, context); |
| 31689 | |
| 31690 | cod_subroutine_declaration("float proc(float p1, unsigned long p2)", |
| 31691 | context); |
| 31692 | gen_code = cod_code_gen(code, context); |
| 31693 | proc = (float (*)(float, unsigned long))(long)gen_code->func; |
| 31694 | |
| 31695 | |
| 31696 | for (i=0 ; i < sizeof(src1f_vals)/sizeof(src1f_vals[0]) ; i++) { |
| 31697 | float source1_f = src1f_vals[i]; |
| 31698 | for (j=0 ; j < sizeof(src2ul_vals)/sizeof(src2ul_vals[0]) ; j++) { |
| 31699 | unsigned long source2_ul = src2ul_vals[j]; |
| 31700 | double range = 0.000001 * (fabs((double)source1_f) + fabs((double)source2_ul)); |
| 31701 | float expected_result; |
| 31702 | float result; |
| 31703 | |
| 31704 | |
| 31705 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 31706 | |
| 31707 | expected_result = (float) (source1_f - source2_ul); |
| 31708 | |
| 31709 | result = proc(source1_f, source2_ul); |
| 31710 | range += 1.0; |
| 31711 | if ((result > (expected_result + range)) || (result < (expected_result - range))) { |
| 31712 | printf("Failed float - unsigned long test, expected %g, got %g, for %g - %lu\n", |
| 31713 | expected_result, result, source1_f, source2_ul); |
| 31714 | if (dumped == 0) cod_dump(gen_code); |
| 31715 | failed++; |
| 31716 | dumped++; |
| 31717 | } |
| 31718 | } |
| 31719 | } |
| 31720 | if (verbose) printf(" done\n"); |
| 31721 | cod_free_parse_context(context); |
| 31722 | cod_code_free(gen_code); |
| 31723 | } |
| 31724 | if ((only_run_test == NULL((void*)0)) || |
| 31725 | (strcmp(only_run_test, "f-l") == 0)) { |
| 31726 | int i, j; |
| 31727 | static char code[] = "{\n\ |
| 31728 | float a = p1;\n\ |
| 31729 | long b = p2;\n\ |
| 31730 | return a - b;\n\ |
| 31731 | }"; |
| 31732 | |
| 31733 | float (*proc)(float a, long b); |
| 31734 | cod_parse_context context = new_cod_parse_context(); |
| 31735 | int dumped = 0; |
| 31736 | |
| 31737 | cod_code gen_code; |
| 31738 | |
| 31739 | /* test for float - long */ |
| 31740 | if (verbose) printf("test for float - long"); |
| 31741 | |
| 31742 | cod_assoc_externs(context, externs); |
| 31743 | cod_parse_for_context(extern_string, context); |
| 31744 | |
| 31745 | cod_subroutine_declaration("float proc(float p1, long p2)", |
| 31746 | context); |
| 31747 | gen_code = cod_code_gen(code, context); |
| 31748 | proc = (float (*)(float, long))(long)gen_code->func; |
| 31749 | |
| 31750 | |
| 31751 | for (i=0 ; i < sizeof(src1f_vals)/sizeof(src1f_vals[0]) ; i++) { |
| 31752 | float source1_f = src1f_vals[i]; |
| 31753 | for (j=0 ; j < sizeof(src2l_vals)/sizeof(src2l_vals[0]) ; j++) { |
| 31754 | long source2_l = src2l_vals[j]; |
| 31755 | double range = 0.000001 * (fabs((double)source1_f) + fabs((double)source2_l)); |
| 31756 | float expected_result; |
| 31757 | float result; |
| 31758 | |
| 31759 | |
| 31760 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 31761 | |
| 31762 | expected_result = (float) (source1_f - source2_l); |
| 31763 | |
| 31764 | result = proc(source1_f, source2_l); |
| 31765 | range += 1.0; |
| 31766 | if ((result > (expected_result + range)) || (result < (expected_result - range))) { |
| 31767 | printf("Failed float - long test, expected %g, got %g, for %g - %ld\n", |
| 31768 | expected_result, result, source1_f, source2_l); |
| 31769 | if (dumped == 0) cod_dump(gen_code); |
| 31770 | failed++; |
| 31771 | dumped++; |
| 31772 | } |
| 31773 | } |
| 31774 | } |
| 31775 | if (verbose) printf(" done\n"); |
| 31776 | cod_free_parse_context(context); |
| 31777 | cod_code_free(gen_code); |
| 31778 | } |
| 31779 | if ((only_run_test == NULL((void*)0)) || |
| 31780 | (strcmp(only_run_test, "f-f") == 0)) { |
| 31781 | int i, j; |
| 31782 | static char code[] = "{\n\ |
| 31783 | float a = p1;\n\ |
| 31784 | float b = p2;\n\ |
| 31785 | return a - b;\n\ |
| 31786 | }"; |
| 31787 | |
| 31788 | float (*proc)(float a, float b); |
| 31789 | cod_parse_context context = new_cod_parse_context(); |
| 31790 | int dumped = 0; |
| 31791 | |
| 31792 | cod_code gen_code; |
| 31793 | |
| 31794 | /* test for float - float */ |
| 31795 | if (verbose) printf("test for float - float"); |
| 31796 | |
| 31797 | cod_assoc_externs(context, externs); |
| 31798 | cod_parse_for_context(extern_string, context); |
| 31799 | |
| 31800 | cod_subroutine_declaration("float proc(float p1, float p2)", |
| 31801 | context); |
| 31802 | gen_code = cod_code_gen(code, context); |
| 31803 | proc = (float (*)(float, float))(long)gen_code->func; |
| 31804 | |
| 31805 | |
| 31806 | for (i=0 ; i < sizeof(src1f_vals)/sizeof(src1f_vals[0]) ; i++) { |
| 31807 | float source1_f = src1f_vals[i]; |
| 31808 | for (j=0 ; j < sizeof(src2f_vals)/sizeof(src2f_vals[0]) ; j++) { |
| 31809 | float source2_f = src2f_vals[j]; |
| 31810 | double range = 0.000001 * (fabs((double)source1_f) + fabs((double)source2_f)); |
| 31811 | float expected_result; |
| 31812 | float result; |
| 31813 | |
| 31814 | |
| 31815 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 31816 | |
| 31817 | expected_result = (float) (source1_f - source2_f); |
| 31818 | |
| 31819 | result = proc(source1_f, source2_f); |
| 31820 | if ((result > (expected_result + range)) || (result < (expected_result - range))) { |
| 31821 | printf("Failed float - float test, expected %g, got %g, for %g - %g\n", |
| 31822 | expected_result, result, source1_f, source2_f); |
| 31823 | if (dumped == 0) cod_dump(gen_code); |
| 31824 | failed++; |
| 31825 | dumped++; |
| 31826 | } |
| 31827 | } |
| 31828 | } |
| 31829 | if (verbose) printf(" done\n"); |
| 31830 | cod_free_parse_context(context); |
| 31831 | cod_code_free(gen_code); |
| 31832 | } |
| 31833 | if ((only_run_test == NULL((void*)0)) || |
| 31834 | (strcmp(only_run_test, "f-d") == 0)) { |
| 31835 | int i, j; |
| 31836 | static char code[] = "{\n\ |
| 31837 | float a = p1;\n\ |
| 31838 | double b = p2;\n\ |
| 31839 | return a - b;\n\ |
| 31840 | }"; |
| 31841 | |
| 31842 | float (*proc)(float a, double b); |
| 31843 | cod_parse_context context = new_cod_parse_context(); |
| 31844 | int dumped = 0; |
| 31845 | |
| 31846 | cod_code gen_code; |
| 31847 | |
| 31848 | /* test for float - double */ |
| 31849 | if (verbose) printf("test for float - double"); |
| 31850 | |
| 31851 | cod_assoc_externs(context, externs); |
| 31852 | cod_parse_for_context(extern_string, context); |
| 31853 | |
| 31854 | cod_subroutine_declaration("float proc(float p1, double p2)", |
| 31855 | context); |
| 31856 | gen_code = cod_code_gen(code, context); |
| 31857 | proc = (float (*)(float, double))(long)gen_code->func; |
| 31858 | |
| 31859 | |
| 31860 | for (i=0 ; i < sizeof(src1f_vals)/sizeof(src1f_vals[0]) ; i++) { |
| 31861 | float source1_f = src1f_vals[i]; |
| 31862 | for (j=0 ; j < sizeof(src2d_vals)/sizeof(src2d_vals[0]) ; j++) { |
| 31863 | double source2_d = src2d_vals[j]; |
| 31864 | double range = 0.000001 * (fabs((double)source1_f) + fabs((double)source2_d)); |
| 31865 | float expected_result; |
| 31866 | float result; |
| 31867 | |
| 31868 | |
| 31869 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 31870 | |
| 31871 | expected_result = (float) (source1_f - source2_d); |
| 31872 | |
| 31873 | result = proc(source1_f, source2_d); |
| 31874 | range += 1.0; |
| 31875 | if ((result > (expected_result + range)) || (result < (expected_result - range))) { |
| 31876 | printf("Failed float - double test, expected %g, got %g, for %g - %g\n", |
| 31877 | expected_result, result, source1_f, source2_d); |
| 31878 | if (dumped == 0) cod_dump(gen_code); |
| 31879 | failed++; |
| 31880 | dumped++; |
| 31881 | } |
| 31882 | } |
| 31883 | } |
| 31884 | if (verbose) printf(" done\n"); |
| 31885 | cod_free_parse_context(context); |
| 31886 | cod_code_free(gen_code); |
| 31887 | } |
| 31888 | } |
| 31889 | void sub_d_tests() |
| 31890 | { |
| 31891 | if ((only_run_test == NULL((void*)0)) || |
| 31892 | (strcmp(only_run_test, "d-c") == 0)) { |
| 31893 | int i, j; |
| 31894 | static char code[] = "{\n\ |
| 31895 | double a = p1;\n\ |
| 31896 | signed char b = p2;\n\ |
| 31897 | return a - b;\n\ |
| 31898 | }"; |
| 31899 | |
| 31900 | double (*proc)(double a, signed char b); |
| 31901 | cod_parse_context context = new_cod_parse_context(); |
| 31902 | int dumped = 0; |
| 31903 | |
| 31904 | cod_code gen_code; |
| 31905 | |
| 31906 | /* test for double - signed char */ |
| 31907 | if (verbose) printf("test for double - signed char"); |
| 31908 | |
| 31909 | cod_assoc_externs(context, externs); |
| 31910 | cod_parse_for_context(extern_string, context); |
| 31911 | |
| 31912 | cod_subroutine_declaration("double proc(double p1, signed char p2)", |
| 31913 | context); |
| 31914 | gen_code = cod_code_gen(code, context); |
| 31915 | proc = (double (*)(double, signed char))(long)gen_code->func; |
| 31916 | |
| 31917 | |
| 31918 | for (i=0 ; i < sizeof(src1d_vals)/sizeof(src1d_vals[0]) ; i++) { |
| 31919 | double source1_d = src1d_vals[i]; |
| 31920 | for (j=0 ; j < sizeof(src2c_vals)/sizeof(src2c_vals[0]) ; j++) { |
| 31921 | signed char source2_c = src2c_vals[j]; |
| 31922 | |
| 31923 | double expected_result; |
| 31924 | double result; |
| 31925 | |
| 31926 | |
| 31927 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 31928 | |
| 31929 | expected_result = (double) (source1_d - source2_c); |
| 31930 | |
| 31931 | result = proc(source1_d, source2_c); |
| 31932 | if (expected_result != result) { |
| 31933 | printf("Failed double - signed char test, expected %g, got %g, for %g - %d\n", |
| 31934 | expected_result, result, source1_d, source2_c); |
| 31935 | if (dumped == 0) cod_dump(gen_code); |
| 31936 | failed++; |
| 31937 | dumped++; |
| 31938 | } |
| 31939 | } |
| 31940 | } |
| 31941 | if (verbose) printf(" done\n"); |
| 31942 | cod_free_parse_context(context); |
| 31943 | cod_code_free(gen_code); |
| 31944 | } |
| 31945 | if ((only_run_test == NULL((void*)0)) || |
| 31946 | (strcmp(only_run_test, "d-uc") == 0)) { |
| 31947 | int i, j; |
| 31948 | static char code[] = "{\n\ |
| 31949 | double a = p1;\n\ |
| 31950 | unsigned char b = p2;\n\ |
| 31951 | return a - b;\n\ |
| 31952 | }"; |
| 31953 | |
| 31954 | double (*proc)(double a, unsigned char b); |
| 31955 | cod_parse_context context = new_cod_parse_context(); |
| 31956 | int dumped = 0; |
| 31957 | |
| 31958 | cod_code gen_code; |
| 31959 | |
| 31960 | /* test for double - unsigned char */ |
| 31961 | if (verbose) printf("test for double - unsigned char"); |
| 31962 | |
| 31963 | cod_assoc_externs(context, externs); |
| 31964 | cod_parse_for_context(extern_string, context); |
| 31965 | |
| 31966 | cod_subroutine_declaration("double proc(double p1, unsigned char p2)", |
| 31967 | context); |
| 31968 | gen_code = cod_code_gen(code, context); |
| 31969 | proc = (double (*)(double, unsigned char))(long)gen_code->func; |
| 31970 | |
| 31971 | |
| 31972 | for (i=0 ; i < sizeof(src1d_vals)/sizeof(src1d_vals[0]) ; i++) { |
| 31973 | double source1_d = src1d_vals[i]; |
| 31974 | for (j=0 ; j < sizeof(src2uc_vals)/sizeof(src2uc_vals[0]) ; j++) { |
| 31975 | unsigned char source2_uc = src2uc_vals[j]; |
| 31976 | |
| 31977 | double expected_result; |
| 31978 | double result; |
| 31979 | |
| 31980 | |
| 31981 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 31982 | |
| 31983 | expected_result = (double) (source1_d - source2_uc); |
| 31984 | |
| 31985 | result = proc(source1_d, source2_uc); |
| 31986 | if (expected_result != result) { |
| 31987 | printf("Failed double - unsigned char test, expected %g, got %g, for %g - %u\n", |
| 31988 | expected_result, result, source1_d, source2_uc); |
| 31989 | if (dumped == 0) cod_dump(gen_code); |
| 31990 | failed++; |
| 31991 | dumped++; |
| 31992 | } |
| 31993 | } |
| 31994 | } |
| 31995 | if (verbose) printf(" done\n"); |
| 31996 | cod_free_parse_context(context); |
| 31997 | cod_code_free(gen_code); |
| 31998 | } |
| 31999 | if ((only_run_test == NULL((void*)0)) || |
| 32000 | (strcmp(only_run_test, "d-s") == 0)) { |
| 32001 | int i, j; |
| 32002 | static char code[] = "{\n\ |
| 32003 | double a = p1;\n\ |
| 32004 | short b = p2;\n\ |
| 32005 | return a - b;\n\ |
| 32006 | }"; |
| 32007 | |
| 32008 | double (*proc)(double a, short b); |
| 32009 | cod_parse_context context = new_cod_parse_context(); |
| 32010 | int dumped = 0; |
| 32011 | |
| 32012 | cod_code gen_code; |
| 32013 | |
| 32014 | /* test for double - short */ |
| 32015 | if (verbose) printf("test for double - short"); |
| 32016 | |
| 32017 | cod_assoc_externs(context, externs); |
| 32018 | cod_parse_for_context(extern_string, context); |
| 32019 | |
| 32020 | cod_subroutine_declaration("double proc(double p1, short p2)", |
| 32021 | context); |
| 32022 | gen_code = cod_code_gen(code, context); |
| 32023 | proc = (double (*)(double, short))(long)gen_code->func; |
| 32024 | |
| 32025 | |
| 32026 | for (i=0 ; i < sizeof(src1d_vals)/sizeof(src1d_vals[0]) ; i++) { |
| 32027 | double source1_d = src1d_vals[i]; |
| 32028 | for (j=0 ; j < sizeof(src2s_vals)/sizeof(src2s_vals[0]) ; j++) { |
| 32029 | short source2_s = src2s_vals[j]; |
| 32030 | |
| 32031 | double expected_result; |
| 32032 | double result; |
| 32033 | |
| 32034 | |
| 32035 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 32036 | |
| 32037 | expected_result = (double) (source1_d - source2_s); |
| 32038 | |
| 32039 | result = proc(source1_d, source2_s); |
| 32040 | if (expected_result != result) { |
| 32041 | printf("Failed double - short test, expected %g, got %g, for %g - %d\n", |
| 32042 | expected_result, result, source1_d, source2_s); |
| 32043 | if (dumped == 0) cod_dump(gen_code); |
| 32044 | failed++; |
| 32045 | dumped++; |
| 32046 | } |
| 32047 | } |
| 32048 | } |
| 32049 | if (verbose) printf(" done\n"); |
| 32050 | cod_free_parse_context(context); |
| 32051 | cod_code_free(gen_code); |
| 32052 | } |
| 32053 | if ((only_run_test == NULL((void*)0)) || |
| 32054 | (strcmp(only_run_test, "d-us") == 0)) { |
| 32055 | int i, j; |
| 32056 | static char code[] = "{\n\ |
| 32057 | double a = p1;\n\ |
| 32058 | unsigned short b = p2;\n\ |
| 32059 | return a - b;\n\ |
| 32060 | }"; |
| 32061 | |
| 32062 | double (*proc)(double a, unsigned short b); |
| 32063 | cod_parse_context context = new_cod_parse_context(); |
| 32064 | int dumped = 0; |
| 32065 | |
| 32066 | cod_code gen_code; |
| 32067 | |
| 32068 | /* test for double - unsigned short */ |
| 32069 | if (verbose) printf("test for double - unsigned short"); |
| 32070 | |
| 32071 | cod_assoc_externs(context, externs); |
| 32072 | cod_parse_for_context(extern_string, context); |
| 32073 | |
| 32074 | cod_subroutine_declaration("double proc(double p1, unsigned short p2)", |
| 32075 | context); |
| 32076 | gen_code = cod_code_gen(code, context); |
| 32077 | proc = (double (*)(double, unsigned short))(long)gen_code->func; |
| 32078 | |
| 32079 | |
| 32080 | for (i=0 ; i < sizeof(src1d_vals)/sizeof(src1d_vals[0]) ; i++) { |
| 32081 | double source1_d = src1d_vals[i]; |
| 32082 | for (j=0 ; j < sizeof(src2us_vals)/sizeof(src2us_vals[0]) ; j++) { |
| 32083 | unsigned short source2_us = src2us_vals[j]; |
| 32084 | |
| 32085 | double expected_result; |
| 32086 | double result; |
| 32087 | |
| 32088 | |
| 32089 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 32090 | |
| 32091 | expected_result = (double) (source1_d - source2_us); |
| 32092 | |
| 32093 | result = proc(source1_d, source2_us); |
| 32094 | if (expected_result != result) { |
| 32095 | printf("Failed double - unsigned short test, expected %g, got %g, for %g - %u\n", |
| 32096 | expected_result, result, source1_d, source2_us); |
| 32097 | if (dumped == 0) cod_dump(gen_code); |
| 32098 | failed++; |
| 32099 | dumped++; |
| 32100 | } |
| 32101 | } |
| 32102 | } |
| 32103 | if (verbose) printf(" done\n"); |
| 32104 | cod_free_parse_context(context); |
| 32105 | cod_code_free(gen_code); |
| 32106 | } |
| 32107 | if ((only_run_test == NULL((void*)0)) || |
| 32108 | (strcmp(only_run_test, "d-i") == 0)) { |
| 32109 | int i, j; |
| 32110 | static char code[] = "{\n\ |
| 32111 | double a = p1;\n\ |
| 32112 | int b = p2;\n\ |
| 32113 | return a - b;\n\ |
| 32114 | }"; |
| 32115 | |
| 32116 | double (*proc)(double a, int b); |
| 32117 | cod_parse_context context = new_cod_parse_context(); |
| 32118 | int dumped = 0; |
| 32119 | |
| 32120 | cod_code gen_code; |
| 32121 | |
| 32122 | /* test for double - int */ |
| 32123 | if (verbose) printf("test for double - int"); |
| 32124 | |
| 32125 | cod_assoc_externs(context, externs); |
| 32126 | cod_parse_for_context(extern_string, context); |
| 32127 | |
| 32128 | cod_subroutine_declaration("double proc(double p1, int p2)", |
| 32129 | context); |
| 32130 | gen_code = cod_code_gen(code, context); |
| 32131 | proc = (double (*)(double, int))(long)gen_code->func; |
| 32132 | |
| 32133 | |
| 32134 | for (i=0 ; i < sizeof(src1d_vals)/sizeof(src1d_vals[0]) ; i++) { |
| 32135 | double source1_d = src1d_vals[i]; |
| 32136 | for (j=0 ; j < sizeof(src2i_vals)/sizeof(src2i_vals[0]) ; j++) { |
| 32137 | int source2_i = src2i_vals[j]; |
| 32138 | |
| 32139 | double expected_result; |
| 32140 | double result; |
| 32141 | |
| 32142 | |
| 32143 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 32144 | |
| 32145 | expected_result = (double) (source1_d - source2_i); |
| 32146 | |
| 32147 | result = proc(source1_d, source2_i); |
| 32148 | if (expected_result != result) { |
| 32149 | printf("Failed double - int test, expected %g, got %g, for %g - %d\n", |
| 32150 | expected_result, result, source1_d, source2_i); |
| 32151 | if (dumped == 0) cod_dump(gen_code); |
| 32152 | failed++; |
| 32153 | dumped++; |
| 32154 | } |
| 32155 | } |
| 32156 | } |
| 32157 | if (verbose) printf(" done\n"); |
| 32158 | cod_free_parse_context(context); |
| 32159 | cod_code_free(gen_code); |
| 32160 | } |
| 32161 | if ((only_run_test == NULL((void*)0)) || |
| 32162 | (strcmp(only_run_test, "d-u") == 0)) { |
| 32163 | int i, j; |
| 32164 | static char code[] = "{\n\ |
| 32165 | double a = p1;\n\ |
| 32166 | unsigned int b = p2;\n\ |
| 32167 | return a - b;\n\ |
| 32168 | }"; |
| 32169 | |
| 32170 | double (*proc)(double a, unsigned int b); |
| 32171 | cod_parse_context context = new_cod_parse_context(); |
| 32172 | int dumped = 0; |
| 32173 | |
| 32174 | cod_code gen_code; |
| 32175 | |
| 32176 | /* test for double - unsigned int */ |
| 32177 | if (verbose) printf("test for double - unsigned int"); |
| 32178 | |
| 32179 | cod_assoc_externs(context, externs); |
| 32180 | cod_parse_for_context(extern_string, context); |
| 32181 | |
| 32182 | cod_subroutine_declaration("double proc(double p1, unsigned int p2)", |
| 32183 | context); |
| 32184 | gen_code = cod_code_gen(code, context); |
| 32185 | proc = (double (*)(double, unsigned int))(long)gen_code->func; |
| 32186 | |
| 32187 | |
| 32188 | for (i=0 ; i < sizeof(src1d_vals)/sizeof(src1d_vals[0]) ; i++) { |
| 32189 | double source1_d = src1d_vals[i]; |
| 32190 | for (j=0 ; j < sizeof(src2u_vals)/sizeof(src2u_vals[0]) ; j++) { |
| 32191 | unsigned int source2_u = src2u_vals[j]; |
| 32192 | |
| 32193 | double expected_result; |
| 32194 | double result; |
| 32195 | |
| 32196 | |
| 32197 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 32198 | |
| 32199 | expected_result = (double) (source1_d - source2_u); |
| 32200 | |
| 32201 | result = proc(source1_d, source2_u); |
| 32202 | if (expected_result != result) { |
| 32203 | printf("Failed double - unsigned int test, expected %g, got %g, for %g - %u\n", |
| 32204 | expected_result, result, source1_d, source2_u); |
| 32205 | if (dumped == 0) cod_dump(gen_code); |
| 32206 | failed++; |
| 32207 | dumped++; |
| 32208 | } |
| 32209 | } |
| 32210 | } |
| 32211 | if (verbose) printf(" done\n"); |
| 32212 | cod_free_parse_context(context); |
| 32213 | cod_code_free(gen_code); |
| 32214 | } |
| 32215 | if ((only_run_test == NULL((void*)0)) || |
| 32216 | (strcmp(only_run_test, "d-ul") == 0)) { |
| 32217 | int i, j; |
| 32218 | static char code[] = "{\n\ |
| 32219 | double a = p1;\n\ |
| 32220 | unsigned long b = p2;\n\ |
| 32221 | return a - b;\n\ |
| 32222 | }"; |
| 32223 | |
| 32224 | double (*proc)(double a, unsigned long b); |
| 32225 | cod_parse_context context = new_cod_parse_context(); |
| 32226 | int dumped = 0; |
| 32227 | |
| 32228 | cod_code gen_code; |
| 32229 | |
| 32230 | /* test for double - unsigned long */ |
| 32231 | if (verbose) printf("test for double - unsigned long"); |
| 32232 | |
| 32233 | cod_assoc_externs(context, externs); |
| 32234 | cod_parse_for_context(extern_string, context); |
| 32235 | |
| 32236 | cod_subroutine_declaration("double proc(double p1, unsigned long p2)", |
| 32237 | context); |
| 32238 | gen_code = cod_code_gen(code, context); |
| 32239 | proc = (double (*)(double, unsigned long))(long)gen_code->func; |
| 32240 | |
| 32241 | |
| 32242 | for (i=0 ; i < sizeof(src1d_vals)/sizeof(src1d_vals[0]) ; i++) { |
| 32243 | double source1_d = src1d_vals[i]; |
| 32244 | for (j=0 ; j < sizeof(src2ul_vals)/sizeof(src2ul_vals[0]) ; j++) { |
| 32245 | unsigned long source2_ul = src2ul_vals[j]; |
| 32246 | |
| 32247 | double expected_result; |
| 32248 | double result; |
| 32249 | |
| 32250 | |
| 32251 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 32252 | |
| 32253 | expected_result = (double) (source1_d - source2_ul); |
| 32254 | |
| 32255 | result = proc(source1_d, source2_ul); |
| 32256 | if (expected_result != result) { |
| 32257 | printf("Failed double - unsigned long test, expected %g, got %g, for %g - %lu\n", |
| 32258 | expected_result, result, source1_d, source2_ul); |
| 32259 | if (dumped == 0) cod_dump(gen_code); |
| 32260 | failed++; |
| 32261 | dumped++; |
| 32262 | } |
| 32263 | } |
| 32264 | } |
| 32265 | if (verbose) printf(" done\n"); |
| 32266 | cod_free_parse_context(context); |
| 32267 | cod_code_free(gen_code); |
| 32268 | } |
| 32269 | if ((only_run_test == NULL((void*)0)) || |
| 32270 | (strcmp(only_run_test, "d-l") == 0)) { |
| 32271 | int i, j; |
| 32272 | static char code[] = "{\n\ |
| 32273 | double a = p1;\n\ |
| 32274 | long b = p2;\n\ |
| 32275 | return a - b;\n\ |
| 32276 | }"; |
| 32277 | |
| 32278 | double (*proc)(double a, long b); |
| 32279 | cod_parse_context context = new_cod_parse_context(); |
| 32280 | int dumped = 0; |
| 32281 | |
| 32282 | cod_code gen_code; |
| 32283 | |
| 32284 | /* test for double - long */ |
| 32285 | if (verbose) printf("test for double - long"); |
| 32286 | |
| 32287 | cod_assoc_externs(context, externs); |
| 32288 | cod_parse_for_context(extern_string, context); |
| 32289 | |
| 32290 | cod_subroutine_declaration("double proc(double p1, long p2)", |
| 32291 | context); |
| 32292 | gen_code = cod_code_gen(code, context); |
| 32293 | proc = (double (*)(double, long))(long)gen_code->func; |
| 32294 | |
| 32295 | |
| 32296 | for (i=0 ; i < sizeof(src1d_vals)/sizeof(src1d_vals[0]) ; i++) { |
| 32297 | double source1_d = src1d_vals[i]; |
| 32298 | for (j=0 ; j < sizeof(src2l_vals)/sizeof(src2l_vals[0]) ; j++) { |
| 32299 | long source2_l = src2l_vals[j]; |
| 32300 | |
| 32301 | double expected_result; |
| 32302 | double result; |
| 32303 | |
| 32304 | |
| 32305 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 32306 | |
| 32307 | expected_result = (double) (source1_d - source2_l); |
| 32308 | |
| 32309 | result = proc(source1_d, source2_l); |
| 32310 | if (expected_result != result) { |
| 32311 | printf("Failed double - long test, expected %g, got %g, for %g - %ld\n", |
| 32312 | expected_result, result, source1_d, source2_l); |
| 32313 | if (dumped == 0) cod_dump(gen_code); |
| 32314 | failed++; |
| 32315 | dumped++; |
| 32316 | } |
| 32317 | } |
| 32318 | } |
| 32319 | if (verbose) printf(" done\n"); |
| 32320 | cod_free_parse_context(context); |
| 32321 | cod_code_free(gen_code); |
| 32322 | } |
| 32323 | if ((only_run_test == NULL((void*)0)) || |
| 32324 | (strcmp(only_run_test, "d-f") == 0)) { |
| 32325 | int i, j; |
| 32326 | static char code[] = "{\n\ |
| 32327 | double a = p1;\n\ |
| 32328 | float b = p2;\n\ |
| 32329 | return a - b;\n\ |
| 32330 | }"; |
| 32331 | |
| 32332 | double (*proc)(double a, float b); |
| 32333 | cod_parse_context context = new_cod_parse_context(); |
| 32334 | int dumped = 0; |
| 32335 | |
| 32336 | cod_code gen_code; |
| 32337 | |
| 32338 | /* test for double - float */ |
| 32339 | if (verbose) printf("test for double - float"); |
| 32340 | |
| 32341 | cod_assoc_externs(context, externs); |
| 32342 | cod_parse_for_context(extern_string, context); |
| 32343 | |
| 32344 | cod_subroutine_declaration("double proc(double p1, float p2)", |
| 32345 | context); |
| 32346 | gen_code = cod_code_gen(code, context); |
| 32347 | proc = (double (*)(double, float))(long)gen_code->func; |
| 32348 | |
| 32349 | |
| 32350 | for (i=0 ; i < sizeof(src1d_vals)/sizeof(src1d_vals[0]) ; i++) { |
| 32351 | double source1_d = src1d_vals[i]; |
| 32352 | for (j=0 ; j < sizeof(src2f_vals)/sizeof(src2f_vals[0]) ; j++) { |
| 32353 | float source2_f = src2f_vals[j]; |
| 32354 | double range = 0.000001 * (fabs((double)source1_d) + fabs((double)source2_f)); |
| 32355 | double expected_result; |
| 32356 | double result; |
| 32357 | |
| 32358 | |
| 32359 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 32360 | |
| 32361 | expected_result = (double) (source1_d - source2_f); |
| 32362 | |
| 32363 | result = proc(source1_d, source2_f); |
| 32364 | range += 1.0; |
| 32365 | if ((result > (expected_result + range)) || (result < (expected_result - range))) { |
| 32366 | printf("Failed double - float test, expected %g, got %g, for %g - %g\n", |
| 32367 | expected_result, result, source1_d, source2_f); |
| 32368 | if (dumped == 0) cod_dump(gen_code); |
| 32369 | failed++; |
| 32370 | dumped++; |
| 32371 | } |
| 32372 | } |
| 32373 | } |
| 32374 | if (verbose) printf(" done\n"); |
| 32375 | cod_free_parse_context(context); |
| 32376 | cod_code_free(gen_code); |
| 32377 | } |
| 32378 | if ((only_run_test == NULL((void*)0)) || |
| 32379 | (strcmp(only_run_test, "d-d") == 0)) { |
| 32380 | int i, j; |
| 32381 | static char code[] = "{\n\ |
| 32382 | double a = p1;\n\ |
| 32383 | double b = p2;\n\ |
| 32384 | return a - b;\n\ |
| 32385 | }"; |
| 32386 | |
| 32387 | double (*proc)(double a, double b); |
| 32388 | cod_parse_context context = new_cod_parse_context(); |
| 32389 | int dumped = 0; |
| 32390 | |
| 32391 | cod_code gen_code; |
| 32392 | |
| 32393 | /* test for double - double */ |
| 32394 | if (verbose) printf("test for double - double"); |
| 32395 | |
| 32396 | cod_assoc_externs(context, externs); |
| 32397 | cod_parse_for_context(extern_string, context); |
| 32398 | |
| 32399 | cod_subroutine_declaration("double proc(double p1, double p2)", |
| 32400 | context); |
| 32401 | gen_code = cod_code_gen(code, context); |
| 32402 | proc = (double (*)(double, double))(long)gen_code->func; |
| 32403 | |
| 32404 | |
| 32405 | for (i=0 ; i < sizeof(src1d_vals)/sizeof(src1d_vals[0]) ; i++) { |
| 32406 | double source1_d = src1d_vals[i]; |
| 32407 | for (j=0 ; j < sizeof(src2d_vals)/sizeof(src2d_vals[0]) ; j++) { |
| 32408 | double source2_d = src2d_vals[j]; |
| 32409 | |
| 32410 | double expected_result; |
| 32411 | double result; |
| 32412 | |
| 32413 | |
| 32414 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 32415 | |
| 32416 | expected_result = (double) (source1_d - source2_d); |
| 32417 | |
| 32418 | result = proc(source1_d, source2_d); |
| 32419 | if (expected_result != result) { |
| 32420 | printf("Failed double - double test, expected %g, got %g, for %g - %g\n", |
| 32421 | expected_result, result, source1_d, source2_d); |
| 32422 | if (dumped == 0) cod_dump(gen_code); |
| 32423 | failed++; |
| 32424 | dumped++; |
| 32425 | } |
| 32426 | } |
| 32427 | } |
| 32428 | if (verbose) printf(" done\n"); |
| 32429 | cod_free_parse_context(context); |
| 32430 | cod_code_free(gen_code); |
| 32431 | } |
| 32432 | } |
| 32433 | void mult_c_tests() |
| 32434 | { |
| 32435 | if ((only_run_test == NULL((void*)0)) || |
| 32436 | (strcmp(only_run_test, "c*c") == 0)) { |
| 32437 | int i, j; |
| 32438 | static char code[] = "{\n\ |
| 32439 | signed char a = p1;\n\ |
| 32440 | signed char b = p2;\n\ |
| 32441 | return a * b;\n\ |
| 32442 | }"; |
| 32443 | |
| 32444 | signed char (*proc)(signed char a, signed char b); |
| 32445 | cod_parse_context context = new_cod_parse_context(); |
| 32446 | int dumped = 0; |
| 32447 | |
| 32448 | cod_code gen_code; |
| 32449 | |
| 32450 | /* test for signed char * signed char */ |
| 32451 | if (verbose) printf("test for signed char * signed char"); |
| 32452 | |
| 32453 | cod_assoc_externs(context, externs); |
| 32454 | cod_parse_for_context(extern_string, context); |
| 32455 | |
| 32456 | cod_subroutine_declaration("signed char proc(signed char p1, signed char p2)", |
| 32457 | context); |
| 32458 | gen_code = cod_code_gen(code, context); |
| 32459 | proc = (signed char (*)(signed char, signed char))(long)gen_code->func; |
| 32460 | |
| 32461 | |
| 32462 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 32463 | signed char source1_c = src1c_vals[i]; |
| 32464 | for (j=0 ; j < sizeof(src2c_vals)/sizeof(src2c_vals[0]) ; j++) { |
| 32465 | signed char source2_c = src2c_vals[j]; |
| 32466 | |
| 32467 | signed char expected_result; |
| 32468 | signed char result; |
| 32469 | |
| 32470 | |
| 32471 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 32472 | |
| 32473 | expected_result = (signed char) (source1_c * source2_c); |
| 32474 | |
| 32475 | result = proc(source1_c, source2_c); |
| 32476 | if (expected_result != result) { |
| 32477 | printf("Failed signed char * signed char test, expected %d, got %d, for %d * %d\n", |
| 32478 | expected_result, result, source1_c, source2_c); |
| 32479 | if (dumped == 0) cod_dump(gen_code); |
| 32480 | failed++; |
| 32481 | dumped++; |
| 32482 | } |
| 32483 | } |
| 32484 | } |
| 32485 | if (verbose) printf(" done\n"); |
| 32486 | cod_free_parse_context(context); |
| 32487 | cod_code_free(gen_code); |
| 32488 | } |
| 32489 | if ((only_run_test == NULL((void*)0)) || |
| 32490 | (strcmp(only_run_test, "c*uc") == 0)) { |
| 32491 | int i, j; |
| 32492 | static char code[] = "{\n\ |
| 32493 | signed char a = p1;\n\ |
| 32494 | unsigned char b = p2;\n\ |
| 32495 | return a * b;\n\ |
| 32496 | }"; |
| 32497 | |
| 32498 | signed char (*proc)(signed char a, unsigned char b); |
| 32499 | cod_parse_context context = new_cod_parse_context(); |
| 32500 | int dumped = 0; |
| 32501 | |
| 32502 | cod_code gen_code; |
| 32503 | |
| 32504 | /* test for signed char * unsigned char */ |
| 32505 | if (verbose) printf("test for signed char * unsigned char"); |
| 32506 | |
| 32507 | cod_assoc_externs(context, externs); |
| 32508 | cod_parse_for_context(extern_string, context); |
| 32509 | |
| 32510 | cod_subroutine_declaration("signed char proc(signed char p1, unsigned char p2)", |
| 32511 | context); |
| 32512 | gen_code = cod_code_gen(code, context); |
| 32513 | proc = (signed char (*)(signed char, unsigned char))(long)gen_code->func; |
| 32514 | |
| 32515 | |
| 32516 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 32517 | signed char source1_c = src1c_vals[i]; |
| 32518 | for (j=0 ; j < sizeof(src2uc_vals)/sizeof(src2uc_vals[0]) ; j++) { |
| 32519 | unsigned char source2_uc = src2uc_vals[j]; |
| 32520 | |
| 32521 | signed char expected_result; |
| 32522 | signed char result; |
| 32523 | |
| 32524 | |
| 32525 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 32526 | |
| 32527 | expected_result = (signed char) (source1_c * source2_uc); |
| 32528 | |
| 32529 | result = proc(source1_c, source2_uc); |
| 32530 | if (expected_result != result) { |
| 32531 | printf("Failed signed char * unsigned char test, expected %d, got %d, for %d * %u\n", |
| 32532 | expected_result, result, source1_c, source2_uc); |
| 32533 | if (dumped == 0) cod_dump(gen_code); |
| 32534 | failed++; |
| 32535 | dumped++; |
| 32536 | } |
| 32537 | } |
| 32538 | } |
| 32539 | if (verbose) printf(" done\n"); |
| 32540 | cod_free_parse_context(context); |
| 32541 | cod_code_free(gen_code); |
| 32542 | } |
| 32543 | if ((only_run_test == NULL((void*)0)) || |
| 32544 | (strcmp(only_run_test, "c*s") == 0)) { |
| 32545 | int i, j; |
| 32546 | static char code[] = "{\n\ |
| 32547 | signed char a = p1;\n\ |
| 32548 | short b = p2;\n\ |
| 32549 | return a * b;\n\ |
| 32550 | }"; |
| 32551 | |
| 32552 | signed char (*proc)(signed char a, short b); |
| 32553 | cod_parse_context context = new_cod_parse_context(); |
| 32554 | int dumped = 0; |
| 32555 | |
| 32556 | cod_code gen_code; |
| 32557 | |
| 32558 | /* test for signed char * short */ |
| 32559 | if (verbose) printf("test for signed char * short"); |
| 32560 | |
| 32561 | cod_assoc_externs(context, externs); |
| 32562 | cod_parse_for_context(extern_string, context); |
| 32563 | |
| 32564 | cod_subroutine_declaration("signed char proc(signed char p1, short p2)", |
| 32565 | context); |
| 32566 | gen_code = cod_code_gen(code, context); |
| 32567 | proc = (signed char (*)(signed char, short))(long)gen_code->func; |
| 32568 | |
| 32569 | |
| 32570 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 32571 | signed char source1_c = src1c_vals[i]; |
| 32572 | for (j=0 ; j < sizeof(src2s_vals)/sizeof(src2s_vals[0]) ; j++) { |
| 32573 | short source2_s = src2s_vals[j]; |
| 32574 | |
| 32575 | signed char expected_result; |
| 32576 | signed char result; |
| 32577 | |
| 32578 | |
| 32579 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 32580 | |
| 32581 | expected_result = (signed char) (source1_c * source2_s); |
| 32582 | |
| 32583 | result = proc(source1_c, source2_s); |
| 32584 | if (expected_result != result) { |
| 32585 | printf("Failed signed char * short test, expected %d, got %d, for %d * %d\n", |
| 32586 | expected_result, result, source1_c, source2_s); |
| 32587 | if (dumped == 0) cod_dump(gen_code); |
| 32588 | failed++; |
| 32589 | dumped++; |
| 32590 | } |
| 32591 | } |
| 32592 | } |
| 32593 | if (verbose) printf(" done\n"); |
| 32594 | cod_free_parse_context(context); |
| 32595 | cod_code_free(gen_code); |
| 32596 | } |
| 32597 | if ((only_run_test == NULL((void*)0)) || |
| 32598 | (strcmp(only_run_test, "c*us") == 0)) { |
| 32599 | int i, j; |
| 32600 | static char code[] = "{\n\ |
| 32601 | signed char a = p1;\n\ |
| 32602 | unsigned short b = p2;\n\ |
| 32603 | return a * b;\n\ |
| 32604 | }"; |
| 32605 | |
| 32606 | signed char (*proc)(signed char a, unsigned short b); |
| 32607 | cod_parse_context context = new_cod_parse_context(); |
| 32608 | int dumped = 0; |
| 32609 | |
| 32610 | cod_code gen_code; |
| 32611 | |
| 32612 | /* test for signed char * unsigned short */ |
| 32613 | if (verbose) printf("test for signed char * unsigned short"); |
| 32614 | |
| 32615 | cod_assoc_externs(context, externs); |
| 32616 | cod_parse_for_context(extern_string, context); |
| 32617 | |
| 32618 | cod_subroutine_declaration("signed char proc(signed char p1, unsigned short p2)", |
| 32619 | context); |
| 32620 | gen_code = cod_code_gen(code, context); |
| 32621 | proc = (signed char (*)(signed char, unsigned short))(long)gen_code->func; |
| 32622 | |
| 32623 | |
| 32624 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 32625 | signed char source1_c = src1c_vals[i]; |
| 32626 | for (j=0 ; j < sizeof(src2us_vals)/sizeof(src2us_vals[0]) ; j++) { |
| 32627 | unsigned short source2_us = src2us_vals[j]; |
| 32628 | |
| 32629 | signed char expected_result; |
| 32630 | signed char result; |
| 32631 | |
| 32632 | |
| 32633 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 32634 | |
| 32635 | expected_result = (signed char) (source1_c * source2_us); |
| 32636 | |
| 32637 | result = proc(source1_c, source2_us); |
| 32638 | if (expected_result != result) { |
| 32639 | printf("Failed signed char * unsigned short test, expected %d, got %d, for %d * %u\n", |
| 32640 | expected_result, result, source1_c, source2_us); |
| 32641 | if (dumped == 0) cod_dump(gen_code); |
| 32642 | failed++; |
| 32643 | dumped++; |
| 32644 | } |
| 32645 | } |
| 32646 | } |
| 32647 | if (verbose) printf(" done\n"); |
| 32648 | cod_free_parse_context(context); |
| 32649 | cod_code_free(gen_code); |
| 32650 | } |
| 32651 | if ((only_run_test == NULL((void*)0)) || |
| 32652 | (strcmp(only_run_test, "c*i") == 0)) { |
| 32653 | int i, j; |
| 32654 | static char code[] = "{\n\ |
| 32655 | signed char a = p1;\n\ |
| 32656 | int b = p2;\n\ |
| 32657 | return a * b;\n\ |
| 32658 | }"; |
| 32659 | |
| 32660 | signed char (*proc)(signed char a, int b); |
| 32661 | cod_parse_context context = new_cod_parse_context(); |
| 32662 | int dumped = 0; |
| 32663 | |
| 32664 | cod_code gen_code; |
| 32665 | |
| 32666 | /* test for signed char * int */ |
| 32667 | if (verbose) printf("test for signed char * int"); |
| 32668 | |
| 32669 | cod_assoc_externs(context, externs); |
| 32670 | cod_parse_for_context(extern_string, context); |
| 32671 | |
| 32672 | cod_subroutine_declaration("signed char proc(signed char p1, int p2)", |
| 32673 | context); |
| 32674 | gen_code = cod_code_gen(code, context); |
| 32675 | proc = (signed char (*)(signed char, int))(long)gen_code->func; |
| 32676 | |
| 32677 | |
| 32678 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 32679 | signed char source1_c = src1c_vals[i]; |
| 32680 | for (j=0 ; j < sizeof(src2i_vals)/sizeof(src2i_vals[0]) ; j++) { |
| 32681 | int source2_i = src2i_vals[j]; |
| 32682 | |
| 32683 | signed char expected_result; |
| 32684 | signed char result; |
| 32685 | |
| 32686 | |
| 32687 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 32688 | |
| 32689 | expected_result = (signed char) (source1_c * source2_i); |
| 32690 | |
| 32691 | result = proc(source1_c, source2_i); |
| 32692 | if (expected_result != result) { |
| 32693 | printf("Failed signed char * int test, expected %d, got %d, for %d * %d\n", |
| 32694 | expected_result, result, source1_c, source2_i); |
| 32695 | if (dumped == 0) cod_dump(gen_code); |
| 32696 | failed++; |
| 32697 | dumped++; |
| 32698 | } |
| 32699 | } |
| 32700 | } |
| 32701 | if (verbose) printf(" done\n"); |
| 32702 | cod_free_parse_context(context); |
| 32703 | cod_code_free(gen_code); |
| 32704 | } |
| 32705 | if ((only_run_test == NULL((void*)0)) || |
| 32706 | (strcmp(only_run_test, "c*u") == 0)) { |
| 32707 | int i, j; |
| 32708 | static char code[] = "{\n\ |
| 32709 | signed char a = p1;\n\ |
| 32710 | unsigned int b = p2;\n\ |
| 32711 | return a * b;\n\ |
| 32712 | }"; |
| 32713 | |
| 32714 | signed char (*proc)(signed char a, unsigned int b); |
| 32715 | cod_parse_context context = new_cod_parse_context(); |
| 32716 | int dumped = 0; |
| 32717 | |
| 32718 | cod_code gen_code; |
| 32719 | |
| 32720 | /* test for signed char * unsigned int */ |
| 32721 | if (verbose) printf("test for signed char * unsigned int"); |
| 32722 | |
| 32723 | cod_assoc_externs(context, externs); |
| 32724 | cod_parse_for_context(extern_string, context); |
| 32725 | |
| 32726 | cod_subroutine_declaration("signed char proc(signed char p1, unsigned int p2)", |
| 32727 | context); |
| 32728 | gen_code = cod_code_gen(code, context); |
| 32729 | proc = (signed char (*)(signed char, unsigned int))(long)gen_code->func; |
| 32730 | |
| 32731 | |
| 32732 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 32733 | signed char source1_c = src1c_vals[i]; |
| 32734 | for (j=0 ; j < sizeof(src2u_vals)/sizeof(src2u_vals[0]) ; j++) { |
| 32735 | unsigned int source2_u = src2u_vals[j]; |
| 32736 | |
| 32737 | signed char expected_result; |
| 32738 | signed char result; |
| 32739 | |
| 32740 | |
| 32741 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 32742 | |
| 32743 | expected_result = (signed char) (source1_c * source2_u); |
| 32744 | |
| 32745 | result = proc(source1_c, source2_u); |
| 32746 | if (expected_result != result) { |
| 32747 | printf("Failed signed char * unsigned int test, expected %d, got %d, for %d * %u\n", |
| 32748 | expected_result, result, source1_c, source2_u); |
| 32749 | if (dumped == 0) cod_dump(gen_code); |
| 32750 | failed++; |
| 32751 | dumped++; |
| 32752 | } |
| 32753 | } |
| 32754 | } |
| 32755 | if (verbose) printf(" done\n"); |
| 32756 | cod_free_parse_context(context); |
| 32757 | cod_code_free(gen_code); |
| 32758 | } |
| 32759 | if ((only_run_test == NULL((void*)0)) || |
| 32760 | (strcmp(only_run_test, "c*ul") == 0)) { |
| 32761 | int i, j; |
| 32762 | static char code[] = "{\n\ |
| 32763 | signed char a = p1;\n\ |
| 32764 | unsigned long b = p2;\n\ |
| 32765 | return a * b;\n\ |
| 32766 | }"; |
| 32767 | |
| 32768 | signed char (*proc)(signed char a, unsigned long b); |
| 32769 | cod_parse_context context = new_cod_parse_context(); |
| 32770 | int dumped = 0; |
| 32771 | |
| 32772 | cod_code gen_code; |
| 32773 | |
| 32774 | /* test for signed char * unsigned long */ |
| 32775 | if (verbose) printf("test for signed char * unsigned long"); |
| 32776 | |
| 32777 | cod_assoc_externs(context, externs); |
| 32778 | cod_parse_for_context(extern_string, context); |
| 32779 | |
| 32780 | cod_subroutine_declaration("signed char proc(signed char p1, unsigned long p2)", |
| 32781 | context); |
| 32782 | gen_code = cod_code_gen(code, context); |
| 32783 | proc = (signed char (*)(signed char, unsigned long))(long)gen_code->func; |
| 32784 | |
| 32785 | |
| 32786 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 32787 | signed char source1_c = src1c_vals[i]; |
| 32788 | for (j=0 ; j < sizeof(src2ul_vals)/sizeof(src2ul_vals[0]) ; j++) { |
| 32789 | unsigned long source2_ul = src2ul_vals[j]; |
| 32790 | |
| 32791 | signed char expected_result; |
| 32792 | signed char result; |
| 32793 | |
| 32794 | |
| 32795 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 32796 | |
| 32797 | expected_result = (signed char) (source1_c * source2_ul); |
| 32798 | |
| 32799 | result = proc(source1_c, source2_ul); |
| 32800 | if (expected_result != result) { |
| 32801 | printf("Failed signed char * unsigned long test, expected %d, got %d, for %d * %lu\n", |
| 32802 | expected_result, result, source1_c, source2_ul); |
| 32803 | if (dumped == 0) cod_dump(gen_code); |
| 32804 | failed++; |
| 32805 | dumped++; |
| 32806 | } |
| 32807 | } |
| 32808 | } |
| 32809 | if (verbose) printf(" done\n"); |
| 32810 | cod_free_parse_context(context); |
| 32811 | cod_code_free(gen_code); |
| 32812 | } |
| 32813 | if ((only_run_test == NULL((void*)0)) || |
| 32814 | (strcmp(only_run_test, "c*l") == 0)) { |
| 32815 | int i, j; |
| 32816 | static char code[] = "{\n\ |
| 32817 | signed char a = p1;\n\ |
| 32818 | long b = p2;\n\ |
| 32819 | return a * b;\n\ |
| 32820 | }"; |
| 32821 | |
| 32822 | signed char (*proc)(signed char a, long b); |
| 32823 | cod_parse_context context = new_cod_parse_context(); |
| 32824 | int dumped = 0; |
| 32825 | |
| 32826 | cod_code gen_code; |
| 32827 | |
| 32828 | /* test for signed char * long */ |
| 32829 | if (verbose) printf("test for signed char * long"); |
| 32830 | |
| 32831 | cod_assoc_externs(context, externs); |
| 32832 | cod_parse_for_context(extern_string, context); |
| 32833 | |
| 32834 | cod_subroutine_declaration("signed char proc(signed char p1, long p2)", |
| 32835 | context); |
| 32836 | gen_code = cod_code_gen(code, context); |
| 32837 | proc = (signed char (*)(signed char, long))(long)gen_code->func; |
| 32838 | |
| 32839 | |
| 32840 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 32841 | signed char source1_c = src1c_vals[i]; |
| 32842 | for (j=0 ; j < sizeof(src2l_vals)/sizeof(src2l_vals[0]) ; j++) { |
| 32843 | long source2_l = src2l_vals[j]; |
| 32844 | |
| 32845 | signed char expected_result; |
| 32846 | signed char result; |
| 32847 | |
| 32848 | |
| 32849 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 32850 | |
| 32851 | expected_result = (signed char) (source1_c * source2_l); |
| 32852 | |
| 32853 | result = proc(source1_c, source2_l); |
| 32854 | if (expected_result != result) { |
| 32855 | printf("Failed signed char * long test, expected %d, got %d, for %d * %ld\n", |
| 32856 | expected_result, result, source1_c, source2_l); |
| 32857 | if (dumped == 0) cod_dump(gen_code); |
| 32858 | failed++; |
| 32859 | dumped++; |
| 32860 | } |
| 32861 | } |
| 32862 | } |
| 32863 | if (verbose) printf(" done\n"); |
| 32864 | cod_free_parse_context(context); |
| 32865 | cod_code_free(gen_code); |
| 32866 | } |
| 32867 | if ((only_run_test == NULL((void*)0)) || |
| 32868 | (strcmp(only_run_test, "c*f") == 0)) { |
| 32869 | int i, j; |
| 32870 | static char code[] = "{\n\ |
| 32871 | signed char a = p1;\n\ |
| 32872 | float b = p2;\n\ |
| 32873 | return a * b;\n\ |
| 32874 | }"; |
| 32875 | |
| 32876 | signed char (*proc)(signed char a, float b); |
| 32877 | cod_parse_context context = new_cod_parse_context(); |
| 32878 | int dumped = 0; |
| 32879 | |
| 32880 | cod_code gen_code; |
| 32881 | |
| 32882 | /* test for signed char * float */ |
| 32883 | if (verbose) printf("test for signed char * float"); |
| 32884 | |
| 32885 | cod_assoc_externs(context, externs); |
| 32886 | cod_parse_for_context(extern_string, context); |
| 32887 | |
| 32888 | cod_subroutine_declaration("signed char proc(signed char p1, float p2)", |
| 32889 | context); |
| 32890 | gen_code = cod_code_gen(code, context); |
| 32891 | proc = (signed char (*)(signed char, float))(long)gen_code->func; |
| 32892 | |
| 32893 | |
| 32894 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 32895 | signed char source1_c = src1c_vals[i]; |
| 32896 | for (j=0 ; j < sizeof(src2f_vals)/sizeof(src2f_vals[0]) ; j++) { |
| 32897 | float source2_f = src2f_vals[j]; |
| 32898 | double range = 0.000001 * (fabs((double)source1_c * (double)source2_f)); |
| 32899 | signed char expected_result; |
| 32900 | signed char result; |
| 32901 | |
| 32902 | |
| 32903 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 32904 | |
| 32905 | expected_result = (signed char) (source1_c * source2_f); |
| 32906 | |
| 32907 | result = proc(source1_c, source2_f); |
| 32908 | range += 1.0; |
| 32909 | if ((result > (expected_result + range)) || (result < (expected_result - range))) { |
| 32910 | printf("Failed signed char * float test, expected %d, got %d, for %d * %g\n", |
| 32911 | expected_result, result, source1_c, source2_f); |
| 32912 | if (dumped == 0) cod_dump(gen_code); |
| 32913 | failed++; |
| 32914 | dumped++; |
| 32915 | } |
| 32916 | } |
| 32917 | } |
| 32918 | if (verbose) printf(" done\n"); |
| 32919 | cod_free_parse_context(context); |
| 32920 | cod_code_free(gen_code); |
| 32921 | } |
| 32922 | if ((only_run_test == NULL((void*)0)) || |
| 32923 | (strcmp(only_run_test, "c*d") == 0)) { |
| 32924 | int i, j; |
| 32925 | static char code[] = "{\n\ |
| 32926 | signed char a = p1;\n\ |
| 32927 | double b = p2;\n\ |
| 32928 | return a * b;\n\ |
| 32929 | }"; |
| 32930 | |
| 32931 | signed char (*proc)(signed char a, double b); |
| 32932 | cod_parse_context context = new_cod_parse_context(); |
| 32933 | int dumped = 0; |
| 32934 | |
| 32935 | cod_code gen_code; |
| 32936 | |
| 32937 | /* test for signed char * double */ |
| 32938 | if (verbose) printf("test for signed char * double"); |
| 32939 | |
| 32940 | cod_assoc_externs(context, externs); |
| 32941 | cod_parse_for_context(extern_string, context); |
| 32942 | |
| 32943 | cod_subroutine_declaration("signed char proc(signed char p1, double p2)", |
| 32944 | context); |
| 32945 | gen_code = cod_code_gen(code, context); |
| 32946 | proc = (signed char (*)(signed char, double))(long)gen_code->func; |
| 32947 | |
| 32948 | |
| 32949 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 32950 | signed char source1_c = src1c_vals[i]; |
| 32951 | for (j=0 ; j < sizeof(src2d_vals)/sizeof(src2d_vals[0]) ; j++) { |
| 32952 | double source2_d = src2d_vals[j]; |
| 32953 | |
| 32954 | signed char expected_result; |
| 32955 | signed char result; |
| 32956 | |
| 32957 | |
| 32958 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 32959 | |
| 32960 | expected_result = (signed char) (source1_c * source2_d); |
| 32961 | |
| 32962 | result = proc(source1_c, source2_d); |
| 32963 | if (expected_result != result) { |
| 32964 | printf("Failed signed char * double test, expected %d, got %d, for %d * %g\n", |
| 32965 | expected_result, result, source1_c, source2_d); |
| 32966 | if (dumped == 0) cod_dump(gen_code); |
| 32967 | failed++; |
| 32968 | dumped++; |
| 32969 | } |
| 32970 | } |
| 32971 | } |
| 32972 | if (verbose) printf(" done\n"); |
| 32973 | cod_free_parse_context(context); |
| 32974 | cod_code_free(gen_code); |
| 32975 | } |
| 32976 | } |
| 32977 | void mult_uc_tests() |
| 32978 | { |
| 32979 | if ((only_run_test == NULL((void*)0)) || |
| 32980 | (strcmp(only_run_test, "uc*c") == 0)) { |
| 32981 | int i, j; |
| 32982 | static char code[] = "{\n\ |
| 32983 | unsigned char a = p1;\n\ |
| 32984 | signed char b = p2;\n\ |
| 32985 | return a * b;\n\ |
| 32986 | }"; |
| 32987 | |
| 32988 | unsigned char (*proc)(unsigned char a, signed char b); |
| 32989 | cod_parse_context context = new_cod_parse_context(); |
| 32990 | int dumped = 0; |
| 32991 | |
| 32992 | cod_code gen_code; |
| 32993 | |
| 32994 | /* test for unsigned char * signed char */ |
| 32995 | if (verbose) printf("test for unsigned char * signed char"); |
| 32996 | |
| 32997 | cod_assoc_externs(context, externs); |
| 32998 | cod_parse_for_context(extern_string, context); |
| 32999 | |
| 33000 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, signed char p2)", |
| 33001 | context); |
| 33002 | gen_code = cod_code_gen(code, context); |
| 33003 | proc = (unsigned char (*)(unsigned char, signed char))(long)gen_code->func; |
| 33004 | |
| 33005 | |
| 33006 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 33007 | unsigned char source1_uc = src1uc_vals[i]; |
| 33008 | for (j=0 ; j < sizeof(src2c_vals)/sizeof(src2c_vals[0]) ; j++) { |
| 33009 | signed char source2_c = src2c_vals[j]; |
| 33010 | |
| 33011 | unsigned char expected_result; |
| 33012 | unsigned char result; |
| 33013 | |
| 33014 | |
| 33015 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 33016 | |
| 33017 | expected_result = (unsigned char) (source1_uc * source2_c); |
| 33018 | |
| 33019 | result = proc(source1_uc, source2_c); |
| 33020 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 33021 | if (expected_result != result) { |
| 33022 | printf("Failed unsigned char * signed char test, expected %u, got %u, for %u * %d\n", |
| 33023 | expected_result, result, source1_uc, source2_c); |
| 33024 | if (dumped == 0) cod_dump(gen_code); |
| 33025 | failed++; |
| 33026 | dumped++; |
| 33027 | } |
| 33028 | } |
| 33029 | } |
| 33030 | if (verbose) printf(" done\n"); |
| 33031 | cod_free_parse_context(context); |
| 33032 | cod_code_free(gen_code); |
| 33033 | } |
| 33034 | if ((only_run_test == NULL((void*)0)) || |
| 33035 | (strcmp(only_run_test, "uc*uc") == 0)) { |
| 33036 | int i, j; |
| 33037 | static char code[] = "{\n\ |
| 33038 | unsigned char a = p1;\n\ |
| 33039 | unsigned char b = p2;\n\ |
| 33040 | return a * b;\n\ |
| 33041 | }"; |
| 33042 | |
| 33043 | unsigned char (*proc)(unsigned char a, unsigned char b); |
| 33044 | cod_parse_context context = new_cod_parse_context(); |
| 33045 | int dumped = 0; |
| 33046 | |
| 33047 | cod_code gen_code; |
| 33048 | |
| 33049 | /* test for unsigned char * unsigned char */ |
| 33050 | if (verbose) printf("test for unsigned char * unsigned char"); |
| 33051 | |
| 33052 | cod_assoc_externs(context, externs); |
| 33053 | cod_parse_for_context(extern_string, context); |
| 33054 | |
| 33055 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, unsigned char p2)", |
| 33056 | context); |
| 33057 | gen_code = cod_code_gen(code, context); |
| 33058 | proc = (unsigned char (*)(unsigned char, unsigned char))(long)gen_code->func; |
| 33059 | |
| 33060 | |
| 33061 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 33062 | unsigned char source1_uc = src1uc_vals[i]; |
| 33063 | for (j=0 ; j < sizeof(src2uc_vals)/sizeof(src2uc_vals[0]) ; j++) { |
| 33064 | unsigned char source2_uc = src2uc_vals[j]; |
| 33065 | |
| 33066 | unsigned char expected_result; |
| 33067 | unsigned char result; |
| 33068 | |
| 33069 | |
| 33070 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 33071 | |
| 33072 | expected_result = (unsigned char) (source1_uc * source2_uc); |
| 33073 | |
| 33074 | result = proc(source1_uc, source2_uc); |
| 33075 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 33076 | if (expected_result != result) { |
| 33077 | printf("Failed unsigned char * unsigned char test, expected %u, got %u, for %u * %u\n", |
| 33078 | expected_result, result, source1_uc, source2_uc); |
| 33079 | if (dumped == 0) cod_dump(gen_code); |
| 33080 | failed++; |
| 33081 | dumped++; |
| 33082 | } |
| 33083 | } |
| 33084 | } |
| 33085 | if (verbose) printf(" done\n"); |
| 33086 | cod_free_parse_context(context); |
| 33087 | cod_code_free(gen_code); |
| 33088 | } |
| 33089 | if ((only_run_test == NULL((void*)0)) || |
| 33090 | (strcmp(only_run_test, "uc*s") == 0)) { |
| 33091 | int i, j; |
| 33092 | static char code[] = "{\n\ |
| 33093 | unsigned char a = p1;\n\ |
| 33094 | short b = p2;\n\ |
| 33095 | return a * b;\n\ |
| 33096 | }"; |
| 33097 | |
| 33098 | unsigned char (*proc)(unsigned char a, short b); |
| 33099 | cod_parse_context context = new_cod_parse_context(); |
| 33100 | int dumped = 0; |
| 33101 | |
| 33102 | cod_code gen_code; |
| 33103 | |
| 33104 | /* test for unsigned char * short */ |
| 33105 | if (verbose) printf("test for unsigned char * short"); |
| 33106 | |
| 33107 | cod_assoc_externs(context, externs); |
| 33108 | cod_parse_for_context(extern_string, context); |
| 33109 | |
| 33110 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, short p2)", |
| 33111 | context); |
| 33112 | gen_code = cod_code_gen(code, context); |
| 33113 | proc = (unsigned char (*)(unsigned char, short))(long)gen_code->func; |
| 33114 | |
| 33115 | |
| 33116 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 33117 | unsigned char source1_uc = src1uc_vals[i]; |
| 33118 | for (j=0 ; j < sizeof(src2s_vals)/sizeof(src2s_vals[0]) ; j++) { |
| 33119 | short source2_s = src2s_vals[j]; |
| 33120 | |
| 33121 | unsigned char expected_result; |
| 33122 | unsigned char result; |
| 33123 | |
| 33124 | |
| 33125 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 33126 | |
| 33127 | expected_result = (unsigned char) (source1_uc * source2_s); |
| 33128 | |
| 33129 | result = proc(source1_uc, source2_s); |
| 33130 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 33131 | if (expected_result != result) { |
| 33132 | printf("Failed unsigned char * short test, expected %u, got %u, for %u * %d\n", |
| 33133 | expected_result, result, source1_uc, source2_s); |
| 33134 | if (dumped == 0) cod_dump(gen_code); |
| 33135 | failed++; |
| 33136 | dumped++; |
| 33137 | } |
| 33138 | } |
| 33139 | } |
| 33140 | if (verbose) printf(" done\n"); |
| 33141 | cod_free_parse_context(context); |
| 33142 | cod_code_free(gen_code); |
| 33143 | } |
| 33144 | if ((only_run_test == NULL((void*)0)) || |
| 33145 | (strcmp(only_run_test, "uc*us") == 0)) { |
| 33146 | int i, j; |
| 33147 | static char code[] = "{\n\ |
| 33148 | unsigned char a = p1;\n\ |
| 33149 | unsigned short b = p2;\n\ |
| 33150 | return a * b;\n\ |
| 33151 | }"; |
| 33152 | |
| 33153 | unsigned char (*proc)(unsigned char a, unsigned short b); |
| 33154 | cod_parse_context context = new_cod_parse_context(); |
| 33155 | int dumped = 0; |
| 33156 | |
| 33157 | cod_code gen_code; |
| 33158 | |
| 33159 | /* test for unsigned char * unsigned short */ |
| 33160 | if (verbose) printf("test for unsigned char * unsigned short"); |
| 33161 | |
| 33162 | cod_assoc_externs(context, externs); |
| 33163 | cod_parse_for_context(extern_string, context); |
| 33164 | |
| 33165 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, unsigned short p2)", |
| 33166 | context); |
| 33167 | gen_code = cod_code_gen(code, context); |
| 33168 | proc = (unsigned char (*)(unsigned char, unsigned short))(long)gen_code->func; |
| 33169 | |
| 33170 | |
| 33171 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 33172 | unsigned char source1_uc = src1uc_vals[i]; |
| 33173 | for (j=0 ; j < sizeof(src2us_vals)/sizeof(src2us_vals[0]) ; j++) { |
| 33174 | unsigned short source2_us = src2us_vals[j]; |
| 33175 | |
| 33176 | unsigned char expected_result; |
| 33177 | unsigned char result; |
| 33178 | |
| 33179 | |
| 33180 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 33181 | |
| 33182 | expected_result = (unsigned char) (source1_uc * source2_us); |
| 33183 | |
| 33184 | result = proc(source1_uc, source2_us); |
| 33185 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 33186 | if (expected_result != result) { |
| 33187 | printf("Failed unsigned char * unsigned short test, expected %u, got %u, for %u * %u\n", |
| 33188 | expected_result, result, source1_uc, source2_us); |
| 33189 | if (dumped == 0) cod_dump(gen_code); |
| 33190 | failed++; |
| 33191 | dumped++; |
| 33192 | } |
| 33193 | } |
| 33194 | } |
| 33195 | if (verbose) printf(" done\n"); |
| 33196 | cod_free_parse_context(context); |
| 33197 | cod_code_free(gen_code); |
| 33198 | } |
| 33199 | if ((only_run_test == NULL((void*)0)) || |
| 33200 | (strcmp(only_run_test, "uc*i") == 0)) { |
| 33201 | int i, j; |
| 33202 | static char code[] = "{\n\ |
| 33203 | unsigned char a = p1;\n\ |
| 33204 | int b = p2;\n\ |
| 33205 | return a * b;\n\ |
| 33206 | }"; |
| 33207 | |
| 33208 | unsigned char (*proc)(unsigned char a, int b); |
| 33209 | cod_parse_context context = new_cod_parse_context(); |
| 33210 | int dumped = 0; |
| 33211 | |
| 33212 | cod_code gen_code; |
| 33213 | |
| 33214 | /* test for unsigned char * int */ |
| 33215 | if (verbose) printf("test for unsigned char * int"); |
| 33216 | |
| 33217 | cod_assoc_externs(context, externs); |
| 33218 | cod_parse_for_context(extern_string, context); |
| 33219 | |
| 33220 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, int p2)", |
| 33221 | context); |
| 33222 | gen_code = cod_code_gen(code, context); |
| 33223 | proc = (unsigned char (*)(unsigned char, int))(long)gen_code->func; |
| 33224 | |
| 33225 | |
| 33226 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 33227 | unsigned char source1_uc = src1uc_vals[i]; |
| 33228 | for (j=0 ; j < sizeof(src2i_vals)/sizeof(src2i_vals[0]) ; j++) { |
| 33229 | int source2_i = src2i_vals[j]; |
| 33230 | |
| 33231 | unsigned char expected_result; |
| 33232 | unsigned char result; |
| 33233 | |
| 33234 | |
| 33235 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 33236 | |
| 33237 | expected_result = (unsigned char) (source1_uc * source2_i); |
| 33238 | |
| 33239 | result = proc(source1_uc, source2_i); |
| 33240 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 33241 | if (expected_result != result) { |
| 33242 | printf("Failed unsigned char * int test, expected %u, got %u, for %u * %d\n", |
| 33243 | expected_result, result, source1_uc, source2_i); |
| 33244 | if (dumped == 0) cod_dump(gen_code); |
| 33245 | failed++; |
| 33246 | dumped++; |
| 33247 | } |
| 33248 | } |
| 33249 | } |
| 33250 | if (verbose) printf(" done\n"); |
| 33251 | cod_free_parse_context(context); |
| 33252 | cod_code_free(gen_code); |
| 33253 | } |
| 33254 | if ((only_run_test == NULL((void*)0)) || |
| 33255 | (strcmp(only_run_test, "uc*u") == 0)) { |
| 33256 | int i, j; |
| 33257 | static char code[] = "{\n\ |
| 33258 | unsigned char a = p1;\n\ |
| 33259 | unsigned int b = p2;\n\ |
| 33260 | return a * b;\n\ |
| 33261 | }"; |
| 33262 | |
| 33263 | unsigned char (*proc)(unsigned char a, unsigned int b); |
| 33264 | cod_parse_context context = new_cod_parse_context(); |
| 33265 | int dumped = 0; |
| 33266 | |
| 33267 | cod_code gen_code; |
| 33268 | |
| 33269 | /* test for unsigned char * unsigned int */ |
| 33270 | if (verbose) printf("test for unsigned char * unsigned int"); |
| 33271 | |
| 33272 | cod_assoc_externs(context, externs); |
| 33273 | cod_parse_for_context(extern_string, context); |
| 33274 | |
| 33275 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, unsigned int p2)", |
| 33276 | context); |
| 33277 | gen_code = cod_code_gen(code, context); |
| 33278 | proc = (unsigned char (*)(unsigned char, unsigned int))(long)gen_code->func; |
| 33279 | |
| 33280 | |
| 33281 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 33282 | unsigned char source1_uc = src1uc_vals[i]; |
| 33283 | for (j=0 ; j < sizeof(src2u_vals)/sizeof(src2u_vals[0]) ; j++) { |
| 33284 | unsigned int source2_u = src2u_vals[j]; |
| 33285 | |
| 33286 | unsigned char expected_result; |
| 33287 | unsigned char result; |
| 33288 | |
| 33289 | |
| 33290 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 33291 | |
| 33292 | expected_result = (unsigned char) (source1_uc * source2_u); |
| 33293 | |
| 33294 | result = proc(source1_uc, source2_u); |
| 33295 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 33296 | if (expected_result != result) { |
| 33297 | printf("Failed unsigned char * unsigned int test, expected %u, got %u, for %u * %u\n", |
| 33298 | expected_result, result, source1_uc, source2_u); |
| 33299 | if (dumped == 0) cod_dump(gen_code); |
| 33300 | failed++; |
| 33301 | dumped++; |
| 33302 | } |
| 33303 | } |
| 33304 | } |
| 33305 | if (verbose) printf(" done\n"); |
| 33306 | cod_free_parse_context(context); |
| 33307 | cod_code_free(gen_code); |
| 33308 | } |
| 33309 | if ((only_run_test == NULL((void*)0)) || |
| 33310 | (strcmp(only_run_test, "uc*ul") == 0)) { |
| 33311 | int i, j; |
| 33312 | static char code[] = "{\n\ |
| 33313 | unsigned char a = p1;\n\ |
| 33314 | unsigned long b = p2;\n\ |
| 33315 | return a * b;\n\ |
| 33316 | }"; |
| 33317 | |
| 33318 | unsigned char (*proc)(unsigned char a, unsigned long b); |
| 33319 | cod_parse_context context = new_cod_parse_context(); |
| 33320 | int dumped = 0; |
| 33321 | |
| 33322 | cod_code gen_code; |
| 33323 | |
| 33324 | /* test for unsigned char * unsigned long */ |
| 33325 | if (verbose) printf("test for unsigned char * unsigned long"); |
| 33326 | |
| 33327 | cod_assoc_externs(context, externs); |
| 33328 | cod_parse_for_context(extern_string, context); |
| 33329 | |
| 33330 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, unsigned long p2)", |
| 33331 | context); |
| 33332 | gen_code = cod_code_gen(code, context); |
| 33333 | proc = (unsigned char (*)(unsigned char, unsigned long))(long)gen_code->func; |
| 33334 | |
| 33335 | |
| 33336 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 33337 | unsigned char source1_uc = src1uc_vals[i]; |
| 33338 | for (j=0 ; j < sizeof(src2ul_vals)/sizeof(src2ul_vals[0]) ; j++) { |
| 33339 | unsigned long source2_ul = src2ul_vals[j]; |
| 33340 | |
| 33341 | unsigned char expected_result; |
| 33342 | unsigned char result; |
| 33343 | |
| 33344 | |
| 33345 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 33346 | |
| 33347 | expected_result = (unsigned char) (source1_uc * source2_ul); |
| 33348 | |
| 33349 | result = proc(source1_uc, source2_ul); |
| 33350 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 33351 | if (expected_result != result) { |
| 33352 | printf("Failed unsigned char * unsigned long test, expected %u, got %u, for %u * %lu\n", |
| 33353 | expected_result, result, source1_uc, source2_ul); |
| 33354 | if (dumped == 0) cod_dump(gen_code); |
| 33355 | failed++; |
| 33356 | dumped++; |
| 33357 | } |
| 33358 | } |
| 33359 | } |
| 33360 | if (verbose) printf(" done\n"); |
| 33361 | cod_free_parse_context(context); |
| 33362 | cod_code_free(gen_code); |
| 33363 | } |
| 33364 | if ((only_run_test == NULL((void*)0)) || |
| 33365 | (strcmp(only_run_test, "uc*l") == 0)) { |
| 33366 | int i, j; |
| 33367 | static char code[] = "{\n\ |
| 33368 | unsigned char a = p1;\n\ |
| 33369 | long b = p2;\n\ |
| 33370 | return a * b;\n\ |
| 33371 | }"; |
| 33372 | |
| 33373 | unsigned char (*proc)(unsigned char a, long b); |
| 33374 | cod_parse_context context = new_cod_parse_context(); |
| 33375 | int dumped = 0; |
| 33376 | |
| 33377 | cod_code gen_code; |
| 33378 | |
| 33379 | /* test for unsigned char * long */ |
| 33380 | if (verbose) printf("test for unsigned char * long"); |
| 33381 | |
| 33382 | cod_assoc_externs(context, externs); |
| 33383 | cod_parse_for_context(extern_string, context); |
| 33384 | |
| 33385 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, long p2)", |
| 33386 | context); |
| 33387 | gen_code = cod_code_gen(code, context); |
| 33388 | proc = (unsigned char (*)(unsigned char, long))(long)gen_code->func; |
| 33389 | |
| 33390 | |
| 33391 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 33392 | unsigned char source1_uc = src1uc_vals[i]; |
| 33393 | for (j=0 ; j < sizeof(src2l_vals)/sizeof(src2l_vals[0]) ; j++) { |
| 33394 | long source2_l = src2l_vals[j]; |
| 33395 | |
| 33396 | unsigned char expected_result; |
| 33397 | unsigned char result; |
| 33398 | |
| 33399 | |
| 33400 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 33401 | |
| 33402 | expected_result = (unsigned char) (source1_uc * source2_l); |
| 33403 | |
| 33404 | result = proc(source1_uc, source2_l); |
| 33405 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 33406 | if (expected_result != result) { |
| 33407 | printf("Failed unsigned char * long test, expected %u, got %u, for %u * %ld\n", |
| 33408 | expected_result, result, source1_uc, source2_l); |
| 33409 | if (dumped == 0) cod_dump(gen_code); |
| 33410 | failed++; |
| 33411 | dumped++; |
| 33412 | } |
| 33413 | } |
| 33414 | } |
| 33415 | if (verbose) printf(" done\n"); |
| 33416 | cod_free_parse_context(context); |
| 33417 | cod_code_free(gen_code); |
| 33418 | } |
| 33419 | if ((only_run_test == NULL((void*)0)) || |
| 33420 | (strcmp(only_run_test, "uc*f") == 0)) { |
| 33421 | int i, j; |
| 33422 | static char code[] = "{\n\ |
| 33423 | unsigned char a = p1;\n\ |
| 33424 | float b = p2;\n\ |
| 33425 | return a * b;\n\ |
| 33426 | }"; |
| 33427 | |
| 33428 | unsigned char (*proc)(unsigned char a, float b); |
| 33429 | cod_parse_context context = new_cod_parse_context(); |
| 33430 | int dumped = 0; |
| 33431 | |
| 33432 | cod_code gen_code; |
| 33433 | |
| 33434 | /* test for unsigned char * float */ |
| 33435 | if (verbose) printf("test for unsigned char * float"); |
| 33436 | |
| 33437 | cod_assoc_externs(context, externs); |
| 33438 | cod_parse_for_context(extern_string, context); |
| 33439 | |
| 33440 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, float p2)", |
| 33441 | context); |
| 33442 | gen_code = cod_code_gen(code, context); |
| 33443 | proc = (unsigned char (*)(unsigned char, float))(long)gen_code->func; |
| 33444 | |
| 33445 | |
| 33446 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 33447 | unsigned char source1_uc = src1uc_vals[i]; |
| 33448 | for (j=0 ; j < sizeof(src2f_vals)/sizeof(src2f_vals[0]) ; j++) { |
| 33449 | float source2_f = src2f_vals[j]; |
| 33450 | double range = 0.000001 * (fabs((double)source1_uc * (double)source2_f)); |
| 33451 | unsigned char expected_result; |
| 33452 | unsigned char result; |
| 33453 | |
| 33454 | |
| 33455 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 33456 | |
| 33457 | expected_result = (unsigned char) (source1_uc * source2_f); |
| 33458 | |
| 33459 | result = proc(source1_uc, source2_f); |
| 33460 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 33461 | range += 1.0; |
| 33462 | if ((result > (expected_result + range)) || (result < (expected_result - range))) { |
| 33463 | printf("Failed unsigned char * float test, expected %u, got %u, for %u * %g\n", |
| 33464 | expected_result, result, source1_uc, source2_f); |
| 33465 | if (dumped == 0) cod_dump(gen_code); |
| 33466 | failed++; |
| 33467 | dumped++; |
| 33468 | } |
| 33469 | } |
| 33470 | } |
| 33471 | if (verbose) printf(" done\n"); |
| 33472 | cod_free_parse_context(context); |
| 33473 | cod_code_free(gen_code); |
| 33474 | } |
| 33475 | if ((only_run_test == NULL((void*)0)) || |
| 33476 | (strcmp(only_run_test, "uc*d") == 0)) { |
| 33477 | int i, j; |
| 33478 | static char code[] = "{\n\ |
| 33479 | unsigned char a = p1;\n\ |
| 33480 | double b = p2;\n\ |
| 33481 | return a * b;\n\ |
| 33482 | }"; |
| 33483 | |
| 33484 | unsigned char (*proc)(unsigned char a, double b); |
| 33485 | cod_parse_context context = new_cod_parse_context(); |
| 33486 | int dumped = 0; |
| 33487 | |
| 33488 | cod_code gen_code; |
| 33489 | |
| 33490 | /* test for unsigned char * double */ |
| 33491 | if (verbose) printf("test for unsigned char * double"); |
| 33492 | |
| 33493 | cod_assoc_externs(context, externs); |
| 33494 | cod_parse_for_context(extern_string, context); |
| 33495 | |
| 33496 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, double p2)", |
| 33497 | context); |
| 33498 | gen_code = cod_code_gen(code, context); |
| 33499 | proc = (unsigned char (*)(unsigned char, double))(long)gen_code->func; |
| 33500 | |
| 33501 | |
| 33502 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 33503 | unsigned char source1_uc = src1uc_vals[i]; |
| 33504 | for (j=0 ; j < sizeof(src2d_vals)/sizeof(src2d_vals[0]) ; j++) { |
| 33505 | double source2_d = src2d_vals[j]; |
| 33506 | |
| 33507 | unsigned char expected_result; |
| 33508 | unsigned char result; |
| 33509 | |
| 33510 | |
| 33511 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 33512 | |
| 33513 | expected_result = (unsigned char) (source1_uc * source2_d); |
| 33514 | |
| 33515 | result = proc(source1_uc, source2_d); |
| 33516 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 33517 | if (expected_result != result) { |
| 33518 | printf("Failed unsigned char * double test, expected %u, got %u, for %u * %g\n", |
| 33519 | expected_result, result, source1_uc, source2_d); |
| 33520 | if (dumped == 0) cod_dump(gen_code); |
| 33521 | failed++; |
| 33522 | dumped++; |
| 33523 | } |
| 33524 | } |
| 33525 | } |
| 33526 | if (verbose) printf(" done\n"); |
| 33527 | cod_free_parse_context(context); |
| 33528 | cod_code_free(gen_code); |
| 33529 | } |
| 33530 | } |
| 33531 | void mult_s_tests() |
| 33532 | { |
| 33533 | if ((only_run_test == NULL((void*)0)) || |
| 33534 | (strcmp(only_run_test, "s*c") == 0)) { |
| 33535 | int i, j; |
| 33536 | static char code[] = "{\n\ |
| 33537 | short a = p1;\n\ |
| 33538 | signed char b = p2;\n\ |
| 33539 | return a * b;\n\ |
| 33540 | }"; |
| 33541 | |
| 33542 | short (*proc)(short a, signed char b); |
| 33543 | cod_parse_context context = new_cod_parse_context(); |
| 33544 | int dumped = 0; |
| 33545 | |
| 33546 | cod_code gen_code; |
| 33547 | |
| 33548 | /* test for short * signed char */ |
| 33549 | if (verbose) printf("test for short * signed char"); |
| 33550 | |
| 33551 | cod_assoc_externs(context, externs); |
| 33552 | cod_parse_for_context(extern_string, context); |
| 33553 | |
| 33554 | cod_subroutine_declaration("short proc(short p1, signed char p2)", |
| 33555 | context); |
| 33556 | gen_code = cod_code_gen(code, context); |
| 33557 | proc = (short (*)(short, signed char))(long)gen_code->func; |
| 33558 | |
| 33559 | |
| 33560 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 33561 | short source1_s = src1s_vals[i]; |
| 33562 | for (j=0 ; j < sizeof(src2c_vals)/sizeof(src2c_vals[0]) ; j++) { |
| 33563 | signed char source2_c = src2c_vals[j]; |
| 33564 | |
| 33565 | short expected_result; |
| 33566 | short result; |
| 33567 | |
| 33568 | |
| 33569 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 33570 | |
| 33571 | expected_result = (short) (source1_s * source2_c); |
| 33572 | |
| 33573 | result = proc(source1_s, source2_c); |
| 33574 | if (expected_result != result) { |
| 33575 | printf("Failed short * signed char test, expected %d, got %d, for %d * %d\n", |
| 33576 | expected_result, result, source1_s, source2_c); |
| 33577 | if (dumped == 0) cod_dump(gen_code); |
| 33578 | failed++; |
| 33579 | dumped++; |
| 33580 | } |
| 33581 | } |
| 33582 | } |
| 33583 | if (verbose) printf(" done\n"); |
| 33584 | cod_free_parse_context(context); |
| 33585 | cod_code_free(gen_code); |
| 33586 | } |
| 33587 | if ((only_run_test == NULL((void*)0)) || |
| 33588 | (strcmp(only_run_test, "s*uc") == 0)) { |
| 33589 | int i, j; |
| 33590 | static char code[] = "{\n\ |
| 33591 | short a = p1;\n\ |
| 33592 | unsigned char b = p2;\n\ |
| 33593 | return a * b;\n\ |
| 33594 | }"; |
| 33595 | |
| 33596 | short (*proc)(short a, unsigned char b); |
| 33597 | cod_parse_context context = new_cod_parse_context(); |
| 33598 | int dumped = 0; |
| 33599 | |
| 33600 | cod_code gen_code; |
| 33601 | |
| 33602 | /* test for short * unsigned char */ |
| 33603 | if (verbose) printf("test for short * unsigned char"); |
| 33604 | |
| 33605 | cod_assoc_externs(context, externs); |
| 33606 | cod_parse_for_context(extern_string, context); |
| 33607 | |
| 33608 | cod_subroutine_declaration("short proc(short p1, unsigned char p2)", |
| 33609 | context); |
| 33610 | gen_code = cod_code_gen(code, context); |
| 33611 | proc = (short (*)(short, unsigned char))(long)gen_code->func; |
| 33612 | |
| 33613 | |
| 33614 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 33615 | short source1_s = src1s_vals[i]; |
| 33616 | for (j=0 ; j < sizeof(src2uc_vals)/sizeof(src2uc_vals[0]) ; j++) { |
| 33617 | unsigned char source2_uc = src2uc_vals[j]; |
| 33618 | |
| 33619 | short expected_result; |
| 33620 | short result; |
| 33621 | |
| 33622 | |
| 33623 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 33624 | |
| 33625 | expected_result = (short) (source1_s * source2_uc); |
| 33626 | |
| 33627 | result = proc(source1_s, source2_uc); |
| 33628 | if (expected_result != result) { |
| 33629 | printf("Failed short * unsigned char test, expected %d, got %d, for %d * %u\n", |
| 33630 | expected_result, result, source1_s, source2_uc); |
| 33631 | if (dumped == 0) cod_dump(gen_code); |
| 33632 | failed++; |
| 33633 | dumped++; |
| 33634 | } |
| 33635 | } |
| 33636 | } |
| 33637 | if (verbose) printf(" done\n"); |
| 33638 | cod_free_parse_context(context); |
| 33639 | cod_code_free(gen_code); |
| 33640 | } |
| 33641 | if ((only_run_test == NULL((void*)0)) || |
| 33642 | (strcmp(only_run_test, "s*s") == 0)) { |
| 33643 | int i, j; |
| 33644 | static char code[] = "{\n\ |
| 33645 | short a = p1;\n\ |
| 33646 | short b = p2;\n\ |
| 33647 | return a * b;\n\ |
| 33648 | }"; |
| 33649 | |
| 33650 | short (*proc)(short a, short b); |
| 33651 | cod_parse_context context = new_cod_parse_context(); |
| 33652 | int dumped = 0; |
| 33653 | |
| 33654 | cod_code gen_code; |
| 33655 | |
| 33656 | /* test for short * short */ |
| 33657 | if (verbose) printf("test for short * short"); |
| 33658 | |
| 33659 | cod_assoc_externs(context, externs); |
| 33660 | cod_parse_for_context(extern_string, context); |
| 33661 | |
| 33662 | cod_subroutine_declaration("short proc(short p1, short p2)", |
| 33663 | context); |
| 33664 | gen_code = cod_code_gen(code, context); |
| 33665 | proc = (short (*)(short, short))(long)gen_code->func; |
| 33666 | |
| 33667 | |
| 33668 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 33669 | short source1_s = src1s_vals[i]; |
| 33670 | for (j=0 ; j < sizeof(src2s_vals)/sizeof(src2s_vals[0]) ; j++) { |
| 33671 | short source2_s = src2s_vals[j]; |
| 33672 | |
| 33673 | short expected_result; |
| 33674 | short result; |
| 33675 | |
| 33676 | |
| 33677 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 33678 | |
| 33679 | expected_result = (short) (source1_s * source2_s); |
| 33680 | |
| 33681 | result = proc(source1_s, source2_s); |
| 33682 | if (expected_result != result) { |
| 33683 | printf("Failed short * short test, expected %d, got %d, for %d * %d\n", |
| 33684 | expected_result, result, source1_s, source2_s); |
| 33685 | if (dumped == 0) cod_dump(gen_code); |
| 33686 | failed++; |
| 33687 | dumped++; |
| 33688 | } |
| 33689 | } |
| 33690 | } |
| 33691 | if (verbose) printf(" done\n"); |
| 33692 | cod_free_parse_context(context); |
| 33693 | cod_code_free(gen_code); |
| 33694 | } |
| 33695 | if ((only_run_test == NULL((void*)0)) || |
| 33696 | (strcmp(only_run_test, "s*us") == 0)) { |
| 33697 | int i, j; |
| 33698 | static char code[] = "{\n\ |
| 33699 | short a = p1;\n\ |
| 33700 | unsigned short b = p2;\n\ |
| 33701 | return a * b;\n\ |
| 33702 | }"; |
| 33703 | |
| 33704 | short (*proc)(short a, unsigned short b); |
| 33705 | cod_parse_context context = new_cod_parse_context(); |
| 33706 | int dumped = 0; |
| 33707 | |
| 33708 | cod_code gen_code; |
| 33709 | |
| 33710 | /* test for short * unsigned short */ |
| 33711 | if (verbose) printf("test for short * unsigned short"); |
| 33712 | |
| 33713 | cod_assoc_externs(context, externs); |
| 33714 | cod_parse_for_context(extern_string, context); |
| 33715 | |
| 33716 | cod_subroutine_declaration("short proc(short p1, unsigned short p2)", |
| 33717 | context); |
| 33718 | gen_code = cod_code_gen(code, context); |
| 33719 | proc = (short (*)(short, unsigned short))(long)gen_code->func; |
| 33720 | |
| 33721 | |
| 33722 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 33723 | short source1_s = src1s_vals[i]; |
| 33724 | for (j=0 ; j < sizeof(src2us_vals)/sizeof(src2us_vals[0]) ; j++) { |
| 33725 | unsigned short source2_us = src2us_vals[j]; |
| 33726 | |
| 33727 | short expected_result; |
| 33728 | short result; |
| 33729 | |
| 33730 | |
| 33731 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 33732 | |
| 33733 | expected_result = (short) (source1_s * source2_us); |
| 33734 | |
| 33735 | result = proc(source1_s, source2_us); |
| 33736 | if (expected_result != result) { |
| 33737 | printf("Failed short * unsigned short test, expected %d, got %d, for %d * %u\n", |
| 33738 | expected_result, result, source1_s, source2_us); |
| 33739 | if (dumped == 0) cod_dump(gen_code); |
| 33740 | failed++; |
| 33741 | dumped++; |
| 33742 | } |
| 33743 | } |
| 33744 | } |
| 33745 | if (verbose) printf(" done\n"); |
| 33746 | cod_free_parse_context(context); |
| 33747 | cod_code_free(gen_code); |
| 33748 | } |
| 33749 | if ((only_run_test == NULL((void*)0)) || |
| 33750 | (strcmp(only_run_test, "s*i") == 0)) { |
| 33751 | int i, j; |
| 33752 | static char code[] = "{\n\ |
| 33753 | short a = p1;\n\ |
| 33754 | int b = p2;\n\ |
| 33755 | return a * b;\n\ |
| 33756 | }"; |
| 33757 | |
| 33758 | short (*proc)(short a, int b); |
| 33759 | cod_parse_context context = new_cod_parse_context(); |
| 33760 | int dumped = 0; |
| 33761 | |
| 33762 | cod_code gen_code; |
| 33763 | |
| 33764 | /* test for short * int */ |
| 33765 | if (verbose) printf("test for short * int"); |
| 33766 | |
| 33767 | cod_assoc_externs(context, externs); |
| 33768 | cod_parse_for_context(extern_string, context); |
| 33769 | |
| 33770 | cod_subroutine_declaration("short proc(short p1, int p2)", |
| 33771 | context); |
| 33772 | gen_code = cod_code_gen(code, context); |
| 33773 | proc = (short (*)(short, int))(long)gen_code->func; |
| 33774 | |
| 33775 | |
| 33776 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 33777 | short source1_s = src1s_vals[i]; |
| 33778 | for (j=0 ; j < sizeof(src2i_vals)/sizeof(src2i_vals[0]) ; j++) { |
| 33779 | int source2_i = src2i_vals[j]; |
| 33780 | |
| 33781 | short expected_result; |
| 33782 | short result; |
| 33783 | |
| 33784 | |
| 33785 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 33786 | |
| 33787 | expected_result = (short) (source1_s * source2_i); |
| 33788 | |
| 33789 | result = proc(source1_s, source2_i); |
| 33790 | if (expected_result != result) { |
| 33791 | printf("Failed short * int test, expected %d, got %d, for %d * %d\n", |
| 33792 | expected_result, result, source1_s, source2_i); |
| 33793 | if (dumped == 0) cod_dump(gen_code); |
| 33794 | failed++; |
| 33795 | dumped++; |
| 33796 | } |
| 33797 | } |
| 33798 | } |
| 33799 | if (verbose) printf(" done\n"); |
| 33800 | cod_free_parse_context(context); |
| 33801 | cod_code_free(gen_code); |
| 33802 | } |
| 33803 | if ((only_run_test == NULL((void*)0)) || |
| 33804 | (strcmp(only_run_test, "s*u") == 0)) { |
| 33805 | int i, j; |
| 33806 | static char code[] = "{\n\ |
| 33807 | short a = p1;\n\ |
| 33808 | unsigned int b = p2;\n\ |
| 33809 | return a * b;\n\ |
| 33810 | }"; |
| 33811 | |
| 33812 | short (*proc)(short a, unsigned int b); |
| 33813 | cod_parse_context context = new_cod_parse_context(); |
| 33814 | int dumped = 0; |
| 33815 | |
| 33816 | cod_code gen_code; |
| 33817 | |
| 33818 | /* test for short * unsigned int */ |
| 33819 | if (verbose) printf("test for short * unsigned int"); |
| 33820 | |
| 33821 | cod_assoc_externs(context, externs); |
| 33822 | cod_parse_for_context(extern_string, context); |
| 33823 | |
| 33824 | cod_subroutine_declaration("short proc(short p1, unsigned int p2)", |
| 33825 | context); |
| 33826 | gen_code = cod_code_gen(code, context); |
| 33827 | proc = (short (*)(short, unsigned int))(long)gen_code->func; |
| 33828 | |
| 33829 | |
| 33830 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 33831 | short source1_s = src1s_vals[i]; |
| 33832 | for (j=0 ; j < sizeof(src2u_vals)/sizeof(src2u_vals[0]) ; j++) { |
| 33833 | unsigned int source2_u = src2u_vals[j]; |
| 33834 | |
| 33835 | short expected_result; |
| 33836 | short result; |
| 33837 | |
| 33838 | |
| 33839 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 33840 | |
| 33841 | expected_result = (short) (source1_s * source2_u); |
| 33842 | |
| 33843 | result = proc(source1_s, source2_u); |
| 33844 | if (expected_result != result) { |
| 33845 | printf("Failed short * unsigned int test, expected %d, got %d, for %d * %u\n", |
| 33846 | expected_result, result, source1_s, source2_u); |
| 33847 | if (dumped == 0) cod_dump(gen_code); |
| 33848 | failed++; |
| 33849 | dumped++; |
| 33850 | } |
| 33851 | } |
| 33852 | } |
| 33853 | if (verbose) printf(" done\n"); |
| 33854 | cod_free_parse_context(context); |
| 33855 | cod_code_free(gen_code); |
| 33856 | } |
| 33857 | if ((only_run_test == NULL((void*)0)) || |
| 33858 | (strcmp(only_run_test, "s*ul") == 0)) { |
| 33859 | int i, j; |
| 33860 | static char code[] = "{\n\ |
| 33861 | short a = p1;\n\ |
| 33862 | unsigned long b = p2;\n\ |
| 33863 | return a * b;\n\ |
| 33864 | }"; |
| 33865 | |
| 33866 | short (*proc)(short a, unsigned long b); |
| 33867 | cod_parse_context context = new_cod_parse_context(); |
| 33868 | int dumped = 0; |
| 33869 | |
| 33870 | cod_code gen_code; |
| 33871 | |
| 33872 | /* test for short * unsigned long */ |
| 33873 | if (verbose) printf("test for short * unsigned long"); |
| 33874 | |
| 33875 | cod_assoc_externs(context, externs); |
| 33876 | cod_parse_for_context(extern_string, context); |
| 33877 | |
| 33878 | cod_subroutine_declaration("short proc(short p1, unsigned long p2)", |
| 33879 | context); |
| 33880 | gen_code = cod_code_gen(code, context); |
| 33881 | proc = (short (*)(short, unsigned long))(long)gen_code->func; |
| 33882 | |
| 33883 | |
| 33884 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 33885 | short source1_s = src1s_vals[i]; |
| 33886 | for (j=0 ; j < sizeof(src2ul_vals)/sizeof(src2ul_vals[0]) ; j++) { |
| 33887 | unsigned long source2_ul = src2ul_vals[j]; |
| 33888 | |
| 33889 | short expected_result; |
| 33890 | short result; |
| 33891 | |
| 33892 | |
| 33893 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 33894 | |
| 33895 | expected_result = (short) (source1_s * source2_ul); |
| 33896 | |
| 33897 | result = proc(source1_s, source2_ul); |
| 33898 | if (expected_result != result) { |
| 33899 | printf("Failed short * unsigned long test, expected %d, got %d, for %d * %lu\n", |
| 33900 | expected_result, result, source1_s, source2_ul); |
| 33901 | if (dumped == 0) cod_dump(gen_code); |
| 33902 | failed++; |
| 33903 | dumped++; |
| 33904 | } |
| 33905 | } |
| 33906 | } |
| 33907 | if (verbose) printf(" done\n"); |
| 33908 | cod_free_parse_context(context); |
| 33909 | cod_code_free(gen_code); |
| 33910 | } |
| 33911 | if ((only_run_test == NULL((void*)0)) || |
| 33912 | (strcmp(only_run_test, "s*l") == 0)) { |
| 33913 | int i, j; |
| 33914 | static char code[] = "{\n\ |
| 33915 | short a = p1;\n\ |
| 33916 | long b = p2;\n\ |
| 33917 | return a * b;\n\ |
| 33918 | }"; |
| 33919 | |
| 33920 | short (*proc)(short a, long b); |
| 33921 | cod_parse_context context = new_cod_parse_context(); |
| 33922 | int dumped = 0; |
| 33923 | |
| 33924 | cod_code gen_code; |
| 33925 | |
| 33926 | /* test for short * long */ |
| 33927 | if (verbose) printf("test for short * long"); |
| 33928 | |
| 33929 | cod_assoc_externs(context, externs); |
| 33930 | cod_parse_for_context(extern_string, context); |
| 33931 | |
| 33932 | cod_subroutine_declaration("short proc(short p1, long p2)", |
| 33933 | context); |
| 33934 | gen_code = cod_code_gen(code, context); |
| 33935 | proc = (short (*)(short, long))(long)gen_code->func; |
| 33936 | |
| 33937 | |
| 33938 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 33939 | short source1_s = src1s_vals[i]; |
| 33940 | for (j=0 ; j < sizeof(src2l_vals)/sizeof(src2l_vals[0]) ; j++) { |
| 33941 | long source2_l = src2l_vals[j]; |
| 33942 | |
| 33943 | short expected_result; |
| 33944 | short result; |
| 33945 | |
| 33946 | |
| 33947 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 33948 | |
| 33949 | expected_result = (short) (source1_s * source2_l); |
| 33950 | |
| 33951 | result = proc(source1_s, source2_l); |
| 33952 | if (expected_result != result) { |
| 33953 | printf("Failed short * long test, expected %d, got %d, for %d * %ld\n", |
| 33954 | expected_result, result, source1_s, source2_l); |
| 33955 | if (dumped == 0) cod_dump(gen_code); |
| 33956 | failed++; |
| 33957 | dumped++; |
| 33958 | } |
| 33959 | } |
| 33960 | } |
| 33961 | if (verbose) printf(" done\n"); |
| 33962 | cod_free_parse_context(context); |
| 33963 | cod_code_free(gen_code); |
| 33964 | } |
| 33965 | if ((only_run_test == NULL((void*)0)) || |
| 33966 | (strcmp(only_run_test, "s*f") == 0)) { |
| 33967 | int i, j; |
| 33968 | static char code[] = "{\n\ |
| 33969 | short a = p1;\n\ |
| 33970 | float b = p2;\n\ |
| 33971 | return a * b;\n\ |
| 33972 | }"; |
| 33973 | |
| 33974 | short (*proc)(short a, float b); |
| 33975 | cod_parse_context context = new_cod_parse_context(); |
| 33976 | int dumped = 0; |
| 33977 | |
| 33978 | cod_code gen_code; |
| 33979 | |
| 33980 | /* test for short * float */ |
| 33981 | if (verbose) printf("test for short * float"); |
| 33982 | |
| 33983 | cod_assoc_externs(context, externs); |
| 33984 | cod_parse_for_context(extern_string, context); |
| 33985 | |
| 33986 | cod_subroutine_declaration("short proc(short p1, float p2)", |
| 33987 | context); |
| 33988 | gen_code = cod_code_gen(code, context); |
| 33989 | proc = (short (*)(short, float))(long)gen_code->func; |
| 33990 | |
| 33991 | |
| 33992 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 33993 | short source1_s = src1s_vals[i]; |
| 33994 | for (j=0 ; j < sizeof(src2f_vals)/sizeof(src2f_vals[0]) ; j++) { |
| 33995 | float source2_f = src2f_vals[j]; |
| 33996 | double range = 0.000001 * (fabs((double)source1_s * (double)source2_f)); |
| 33997 | short expected_result; |
| 33998 | short result; |
| 33999 | |
| 34000 | |
| 34001 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 34002 | |
| 34003 | expected_result = (short) (source1_s * source2_f); |
| 34004 | |
| 34005 | result = proc(source1_s, source2_f); |
| 34006 | range += 1.0; |
| 34007 | if ((result > (expected_result + range)) || (result < (expected_result - range))) { |
| 34008 | printf("Failed short * float test, expected %d, got %d, for %d * %g\n", |
| 34009 | expected_result, result, source1_s, source2_f); |
| 34010 | if (dumped == 0) cod_dump(gen_code); |
| 34011 | failed++; |
| 34012 | dumped++; |
| 34013 | } |
| 34014 | } |
| 34015 | } |
| 34016 | if (verbose) printf(" done\n"); |
| 34017 | cod_free_parse_context(context); |
| 34018 | cod_code_free(gen_code); |
| 34019 | } |
| 34020 | if ((only_run_test == NULL((void*)0)) || |
| 34021 | (strcmp(only_run_test, "s*d") == 0)) { |
| 34022 | int i, j; |
| 34023 | static char code[] = "{\n\ |
| 34024 | short a = p1;\n\ |
| 34025 | double b = p2;\n\ |
| 34026 | return a * b;\n\ |
| 34027 | }"; |
| 34028 | |
| 34029 | short (*proc)(short a, double b); |
| 34030 | cod_parse_context context = new_cod_parse_context(); |
| 34031 | int dumped = 0; |
| 34032 | |
| 34033 | cod_code gen_code; |
| 34034 | |
| 34035 | /* test for short * double */ |
| 34036 | if (verbose) printf("test for short * double"); |
| 34037 | |
| 34038 | cod_assoc_externs(context, externs); |
| 34039 | cod_parse_for_context(extern_string, context); |
| 34040 | |
| 34041 | cod_subroutine_declaration("short proc(short p1, double p2)", |
| 34042 | context); |
| 34043 | gen_code = cod_code_gen(code, context); |
| 34044 | proc = (short (*)(short, double))(long)gen_code->func; |
| 34045 | |
| 34046 | |
| 34047 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 34048 | short source1_s = src1s_vals[i]; |
| 34049 | for (j=0 ; j < sizeof(src2d_vals)/sizeof(src2d_vals[0]) ; j++) { |
| 34050 | double source2_d = src2d_vals[j]; |
| 34051 | |
| 34052 | short expected_result; |
| 34053 | short result; |
| 34054 | |
| 34055 | |
| 34056 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 34057 | |
| 34058 | expected_result = (short) (source1_s * source2_d); |
| 34059 | |
| 34060 | result = proc(source1_s, source2_d); |
| 34061 | if (expected_result != result) { |
| 34062 | printf("Failed short * double test, expected %d, got %d, for %d * %g\n", |
| 34063 | expected_result, result, source1_s, source2_d); |
| 34064 | if (dumped == 0) cod_dump(gen_code); |
| 34065 | failed++; |
| 34066 | dumped++; |
| 34067 | } |
| 34068 | } |
| 34069 | } |
| 34070 | if (verbose) printf(" done\n"); |
| 34071 | cod_free_parse_context(context); |
| 34072 | cod_code_free(gen_code); |
| 34073 | } |
| 34074 | } |
| 34075 | void mult_us_tests() |
| 34076 | { |
| 34077 | if ((only_run_test == NULL((void*)0)) || |
| 34078 | (strcmp(only_run_test, "us*c") == 0)) { |
| 34079 | int i, j; |
| 34080 | static char code[] = "{\n\ |
| 34081 | unsigned short a = p1;\n\ |
| 34082 | signed char b = p2;\n\ |
| 34083 | return a * b;\n\ |
| 34084 | }"; |
| 34085 | |
| 34086 | unsigned short (*proc)(unsigned short a, signed char b); |
| 34087 | cod_parse_context context = new_cod_parse_context(); |
| 34088 | int dumped = 0; |
| 34089 | |
| 34090 | cod_code gen_code; |
| 34091 | |
| 34092 | /* test for unsigned short * signed char */ |
| 34093 | if (verbose) printf("test for unsigned short * signed char"); |
| 34094 | |
| 34095 | cod_assoc_externs(context, externs); |
| 34096 | cod_parse_for_context(extern_string, context); |
| 34097 | |
| 34098 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, signed char p2)", |
| 34099 | context); |
| 34100 | gen_code = cod_code_gen(code, context); |
| 34101 | proc = (unsigned short (*)(unsigned short, signed char))(long)gen_code->func; |
| 34102 | |
| 34103 | |
| 34104 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 34105 | unsigned short source1_us = src1us_vals[i]; |
| 34106 | for (j=0 ; j < sizeof(src2c_vals)/sizeof(src2c_vals[0]) ; j++) { |
| 34107 | signed char source2_c = src2c_vals[j]; |
| 34108 | |
| 34109 | unsigned short expected_result; |
| 34110 | unsigned short result; |
| 34111 | |
| 34112 | |
| 34113 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 34114 | |
| 34115 | expected_result = (unsigned short) (source1_us * source2_c); |
| 34116 | |
| 34117 | result = proc(source1_us, source2_c); |
| 34118 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 34119 | if (expected_result != result) { |
| 34120 | printf("Failed unsigned short * signed char test, expected %u, got %u, for %u * %d\n", |
| 34121 | expected_result, result, source1_us, source2_c); |
| 34122 | if (dumped == 0) cod_dump(gen_code); |
| 34123 | failed++; |
| 34124 | dumped++; |
| 34125 | } |
| 34126 | } |
| 34127 | } |
| 34128 | if (verbose) printf(" done\n"); |
| 34129 | cod_free_parse_context(context); |
| 34130 | cod_code_free(gen_code); |
| 34131 | } |
| 34132 | if ((only_run_test == NULL((void*)0)) || |
| 34133 | (strcmp(only_run_test, "us*uc") == 0)) { |
| 34134 | int i, j; |
| 34135 | static char code[] = "{\n\ |
| 34136 | unsigned short a = p1;\n\ |
| 34137 | unsigned char b = p2;\n\ |
| 34138 | return a * b;\n\ |
| 34139 | }"; |
| 34140 | |
| 34141 | unsigned short (*proc)(unsigned short a, unsigned char b); |
| 34142 | cod_parse_context context = new_cod_parse_context(); |
| 34143 | int dumped = 0; |
| 34144 | |
| 34145 | cod_code gen_code; |
| 34146 | |
| 34147 | /* test for unsigned short * unsigned char */ |
| 34148 | if (verbose) printf("test for unsigned short * unsigned char"); |
| 34149 | |
| 34150 | cod_assoc_externs(context, externs); |
| 34151 | cod_parse_for_context(extern_string, context); |
| 34152 | |
| 34153 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, unsigned char p2)", |
| 34154 | context); |
| 34155 | gen_code = cod_code_gen(code, context); |
| 34156 | proc = (unsigned short (*)(unsigned short, unsigned char))(long)gen_code->func; |
| 34157 | |
| 34158 | |
| 34159 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 34160 | unsigned short source1_us = src1us_vals[i]; |
| 34161 | for (j=0 ; j < sizeof(src2uc_vals)/sizeof(src2uc_vals[0]) ; j++) { |
| 34162 | unsigned char source2_uc = src2uc_vals[j]; |
| 34163 | |
| 34164 | unsigned short expected_result; |
| 34165 | unsigned short result; |
| 34166 | |
| 34167 | |
| 34168 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 34169 | |
| 34170 | expected_result = (unsigned short) (source1_us * source2_uc); |
| 34171 | |
| 34172 | result = proc(source1_us, source2_uc); |
| 34173 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 34174 | if (expected_result != result) { |
| 34175 | printf("Failed unsigned short * unsigned char test, expected %u, got %u, for %u * %u\n", |
| 34176 | expected_result, result, source1_us, source2_uc); |
| 34177 | if (dumped == 0) cod_dump(gen_code); |
| 34178 | failed++; |
| 34179 | dumped++; |
| 34180 | } |
| 34181 | } |
| 34182 | } |
| 34183 | if (verbose) printf(" done\n"); |
| 34184 | cod_free_parse_context(context); |
| 34185 | cod_code_free(gen_code); |
| 34186 | } |
| 34187 | if ((only_run_test == NULL((void*)0)) || |
| 34188 | (strcmp(only_run_test, "us*s") == 0)) { |
| 34189 | int i, j; |
| 34190 | static char code[] = "{\n\ |
| 34191 | unsigned short a = p1;\n\ |
| 34192 | short b = p2;\n\ |
| 34193 | return a * b;\n\ |
| 34194 | }"; |
| 34195 | |
| 34196 | unsigned short (*proc)(unsigned short a, short b); |
| 34197 | cod_parse_context context = new_cod_parse_context(); |
| 34198 | int dumped = 0; |
| 34199 | |
| 34200 | cod_code gen_code; |
| 34201 | |
| 34202 | /* test for unsigned short * short */ |
| 34203 | if (verbose) printf("test for unsigned short * short"); |
| 34204 | |
| 34205 | cod_assoc_externs(context, externs); |
| 34206 | cod_parse_for_context(extern_string, context); |
| 34207 | |
| 34208 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, short p2)", |
| 34209 | context); |
| 34210 | gen_code = cod_code_gen(code, context); |
| 34211 | proc = (unsigned short (*)(unsigned short, short))(long)gen_code->func; |
| 34212 | |
| 34213 | |
| 34214 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 34215 | unsigned short source1_us = src1us_vals[i]; |
| 34216 | for (j=0 ; j < sizeof(src2s_vals)/sizeof(src2s_vals[0]) ; j++) { |
| 34217 | short source2_s = src2s_vals[j]; |
| 34218 | |
| 34219 | unsigned short expected_result; |
| 34220 | unsigned short result; |
| 34221 | |
| 34222 | |
| 34223 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 34224 | |
| 34225 | expected_result = (unsigned short) (source1_us * source2_s); |
| 34226 | |
| 34227 | result = proc(source1_us, source2_s); |
| 34228 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 34229 | if (expected_result != result) { |
| 34230 | printf("Failed unsigned short * short test, expected %u, got %u, for %u * %d\n", |
| 34231 | expected_result, result, source1_us, source2_s); |
| 34232 | if (dumped == 0) cod_dump(gen_code); |
| 34233 | failed++; |
| 34234 | dumped++; |
| 34235 | } |
| 34236 | } |
| 34237 | } |
| 34238 | if (verbose) printf(" done\n"); |
| 34239 | cod_free_parse_context(context); |
| 34240 | cod_code_free(gen_code); |
| 34241 | } |
| 34242 | if ((only_run_test == NULL((void*)0)) || |
| 34243 | (strcmp(only_run_test, "us*us") == 0)) { |
| 34244 | int i, j; |
| 34245 | static char code[] = "{\n\ |
| 34246 | unsigned short a = p1;\n\ |
| 34247 | unsigned short b = p2;\n\ |
| 34248 | return a * b;\n\ |
| 34249 | }"; |
| 34250 | |
| 34251 | unsigned short (*proc)(unsigned short a, unsigned short b); |
| 34252 | cod_parse_context context = new_cod_parse_context(); |
| 34253 | int dumped = 0; |
| 34254 | |
| 34255 | cod_code gen_code; |
| 34256 | |
| 34257 | /* test for unsigned short * unsigned short */ |
| 34258 | if (verbose) printf("test for unsigned short * unsigned short"); |
| 34259 | |
| 34260 | cod_assoc_externs(context, externs); |
| 34261 | cod_parse_for_context(extern_string, context); |
| 34262 | |
| 34263 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, unsigned short p2)", |
| 34264 | context); |
| 34265 | gen_code = cod_code_gen(code, context); |
| 34266 | proc = (unsigned short (*)(unsigned short, unsigned short))(long)gen_code->func; |
| 34267 | |
| 34268 | |
| 34269 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 34270 | unsigned short source1_us = src1us_vals[i]; |
| 34271 | for (j=0 ; j < sizeof(src2us_vals)/sizeof(src2us_vals[0]) ; j++) { |
| 34272 | unsigned short source2_us = src2us_vals[j]; |
| 34273 | |
| 34274 | unsigned short expected_result; |
| 34275 | unsigned short result; |
| 34276 | |
| 34277 | |
| 34278 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 34279 | |
| 34280 | expected_result = (unsigned short) (source1_us * source2_us); |
| 34281 | |
| 34282 | result = proc(source1_us, source2_us); |
| 34283 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 34284 | if (expected_result != result) { |
| 34285 | printf("Failed unsigned short * unsigned short test, expected %u, got %u, for %u * %u\n", |
| 34286 | expected_result, result, source1_us, source2_us); |
| 34287 | if (dumped == 0) cod_dump(gen_code); |
| 34288 | failed++; |
| 34289 | dumped++; |
| 34290 | } |
| 34291 | } |
| 34292 | } |
| 34293 | if (verbose) printf(" done\n"); |
| 34294 | cod_free_parse_context(context); |
| 34295 | cod_code_free(gen_code); |
| 34296 | } |
| 34297 | if ((only_run_test == NULL((void*)0)) || |
| 34298 | (strcmp(only_run_test, "us*i") == 0)) { |
| 34299 | int i, j; |
| 34300 | static char code[] = "{\n\ |
| 34301 | unsigned short a = p1;\n\ |
| 34302 | int b = p2;\n\ |
| 34303 | return a * b;\n\ |
| 34304 | }"; |
| 34305 | |
| 34306 | unsigned short (*proc)(unsigned short a, int b); |
| 34307 | cod_parse_context context = new_cod_parse_context(); |
| 34308 | int dumped = 0; |
| 34309 | |
| 34310 | cod_code gen_code; |
| 34311 | |
| 34312 | /* test for unsigned short * int */ |
| 34313 | if (verbose) printf("test for unsigned short * int"); |
| 34314 | |
| 34315 | cod_assoc_externs(context, externs); |
| 34316 | cod_parse_for_context(extern_string, context); |
| 34317 | |
| 34318 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, int p2)", |
| 34319 | context); |
| 34320 | gen_code = cod_code_gen(code, context); |
| 34321 | proc = (unsigned short (*)(unsigned short, int))(long)gen_code->func; |
| 34322 | |
| 34323 | |
| 34324 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 34325 | unsigned short source1_us = src1us_vals[i]; |
| 34326 | for (j=0 ; j < sizeof(src2i_vals)/sizeof(src2i_vals[0]) ; j++) { |
| 34327 | int source2_i = src2i_vals[j]; |
| 34328 | |
| 34329 | unsigned short expected_result; |
| 34330 | unsigned short result; |
| 34331 | |
| 34332 | |
| 34333 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 34334 | |
| 34335 | expected_result = (unsigned short) (source1_us * source2_i); |
| 34336 | |
| 34337 | result = proc(source1_us, source2_i); |
| 34338 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 34339 | if (expected_result != result) { |
| 34340 | printf("Failed unsigned short * int test, expected %u, got %u, for %u * %d\n", |
| 34341 | expected_result, result, source1_us, source2_i); |
| 34342 | if (dumped == 0) cod_dump(gen_code); |
| 34343 | failed++; |
| 34344 | dumped++; |
| 34345 | } |
| 34346 | } |
| 34347 | } |
| 34348 | if (verbose) printf(" done\n"); |
| 34349 | cod_free_parse_context(context); |
| 34350 | cod_code_free(gen_code); |
| 34351 | } |
| 34352 | if ((only_run_test == NULL((void*)0)) || |
| 34353 | (strcmp(only_run_test, "us*u") == 0)) { |
| 34354 | int i, j; |
| 34355 | static char code[] = "{\n\ |
| 34356 | unsigned short a = p1;\n\ |
| 34357 | unsigned int b = p2;\n\ |
| 34358 | return a * b;\n\ |
| 34359 | }"; |
| 34360 | |
| 34361 | unsigned short (*proc)(unsigned short a, unsigned int b); |
| 34362 | cod_parse_context context = new_cod_parse_context(); |
| 34363 | int dumped = 0; |
| 34364 | |
| 34365 | cod_code gen_code; |
| 34366 | |
| 34367 | /* test for unsigned short * unsigned int */ |
| 34368 | if (verbose) printf("test for unsigned short * unsigned int"); |
| 34369 | |
| 34370 | cod_assoc_externs(context, externs); |
| 34371 | cod_parse_for_context(extern_string, context); |
| 34372 | |
| 34373 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, unsigned int p2)", |
| 34374 | context); |
| 34375 | gen_code = cod_code_gen(code, context); |
| 34376 | proc = (unsigned short (*)(unsigned short, unsigned int))(long)gen_code->func; |
| 34377 | |
| 34378 | |
| 34379 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 34380 | unsigned short source1_us = src1us_vals[i]; |
| 34381 | for (j=0 ; j < sizeof(src2u_vals)/sizeof(src2u_vals[0]) ; j++) { |
| 34382 | unsigned int source2_u = src2u_vals[j]; |
| 34383 | |
| 34384 | unsigned short expected_result; |
| 34385 | unsigned short result; |
| 34386 | |
| 34387 | |
| 34388 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 34389 | |
| 34390 | expected_result = (unsigned short) (source1_us * source2_u); |
| 34391 | |
| 34392 | result = proc(source1_us, source2_u); |
| 34393 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 34394 | if (expected_result != result) { |
| 34395 | printf("Failed unsigned short * unsigned int test, expected %u, got %u, for %u * %u\n", |
| 34396 | expected_result, result, source1_us, source2_u); |
| 34397 | if (dumped == 0) cod_dump(gen_code); |
| 34398 | failed++; |
| 34399 | dumped++; |
| 34400 | } |
| 34401 | } |
| 34402 | } |
| 34403 | if (verbose) printf(" done\n"); |
| 34404 | cod_free_parse_context(context); |
| 34405 | cod_code_free(gen_code); |
| 34406 | } |
| 34407 | if ((only_run_test == NULL((void*)0)) || |
| 34408 | (strcmp(only_run_test, "us*ul") == 0)) { |
| 34409 | int i, j; |
| 34410 | static char code[] = "{\n\ |
| 34411 | unsigned short a = p1;\n\ |
| 34412 | unsigned long b = p2;\n\ |
| 34413 | return a * b;\n\ |
| 34414 | }"; |
| 34415 | |
| 34416 | unsigned short (*proc)(unsigned short a, unsigned long b); |
| 34417 | cod_parse_context context = new_cod_parse_context(); |
| 34418 | int dumped = 0; |
| 34419 | |
| 34420 | cod_code gen_code; |
| 34421 | |
| 34422 | /* test for unsigned short * unsigned long */ |
| 34423 | if (verbose) printf("test for unsigned short * unsigned long"); |
| 34424 | |
| 34425 | cod_assoc_externs(context, externs); |
| 34426 | cod_parse_for_context(extern_string, context); |
| 34427 | |
| 34428 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, unsigned long p2)", |
| 34429 | context); |
| 34430 | gen_code = cod_code_gen(code, context); |
| 34431 | proc = (unsigned short (*)(unsigned short, unsigned long))(long)gen_code->func; |
| 34432 | |
| 34433 | |
| 34434 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 34435 | unsigned short source1_us = src1us_vals[i]; |
| 34436 | for (j=0 ; j < sizeof(src2ul_vals)/sizeof(src2ul_vals[0]) ; j++) { |
| 34437 | unsigned long source2_ul = src2ul_vals[j]; |
| 34438 | |
| 34439 | unsigned short expected_result; |
| 34440 | unsigned short result; |
| 34441 | |
| 34442 | |
| 34443 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 34444 | |
| 34445 | expected_result = (unsigned short) (source1_us * source2_ul); |
| 34446 | |
| 34447 | result = proc(source1_us, source2_ul); |
| 34448 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 34449 | if (expected_result != result) { |
| 34450 | printf("Failed unsigned short * unsigned long test, expected %u, got %u, for %u * %lu\n", |
| 34451 | expected_result, result, source1_us, source2_ul); |
| 34452 | if (dumped == 0) cod_dump(gen_code); |
| 34453 | failed++; |
| 34454 | dumped++; |
| 34455 | } |
| 34456 | } |
| 34457 | } |
| 34458 | if (verbose) printf(" done\n"); |
| 34459 | cod_free_parse_context(context); |
| 34460 | cod_code_free(gen_code); |
| 34461 | } |
| 34462 | if ((only_run_test == NULL((void*)0)) || |
| 34463 | (strcmp(only_run_test, "us*l") == 0)) { |
| 34464 | int i, j; |
| 34465 | static char code[] = "{\n\ |
| 34466 | unsigned short a = p1;\n\ |
| 34467 | long b = p2;\n\ |
| 34468 | return a * b;\n\ |
| 34469 | }"; |
| 34470 | |
| 34471 | unsigned short (*proc)(unsigned short a, long b); |
| 34472 | cod_parse_context context = new_cod_parse_context(); |
| 34473 | int dumped = 0; |
| 34474 | |
| 34475 | cod_code gen_code; |
| 34476 | |
| 34477 | /* test for unsigned short * long */ |
| 34478 | if (verbose) printf("test for unsigned short * long"); |
| 34479 | |
| 34480 | cod_assoc_externs(context, externs); |
| 34481 | cod_parse_for_context(extern_string, context); |
| 34482 | |
| 34483 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, long p2)", |
| 34484 | context); |
| 34485 | gen_code = cod_code_gen(code, context); |
| 34486 | proc = (unsigned short (*)(unsigned short, long))(long)gen_code->func; |
| 34487 | |
| 34488 | |
| 34489 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 34490 | unsigned short source1_us = src1us_vals[i]; |
| 34491 | for (j=0 ; j < sizeof(src2l_vals)/sizeof(src2l_vals[0]) ; j++) { |
| 34492 | long source2_l = src2l_vals[j]; |
| 34493 | |
| 34494 | unsigned short expected_result; |
| 34495 | unsigned short result; |
| 34496 | |
| 34497 | |
| 34498 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 34499 | |
| 34500 | expected_result = (unsigned short) (source1_us * source2_l); |
| 34501 | |
| 34502 | result = proc(source1_us, source2_l); |
| 34503 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 34504 | if (expected_result != result) { |
| 34505 | printf("Failed unsigned short * long test, expected %u, got %u, for %u * %ld\n", |
| 34506 | expected_result, result, source1_us, source2_l); |
| 34507 | if (dumped == 0) cod_dump(gen_code); |
| 34508 | failed++; |
| 34509 | dumped++; |
| 34510 | } |
| 34511 | } |
| 34512 | } |
| 34513 | if (verbose) printf(" done\n"); |
| 34514 | cod_free_parse_context(context); |
| 34515 | cod_code_free(gen_code); |
| 34516 | } |
| 34517 | if ((only_run_test == NULL((void*)0)) || |
| 34518 | (strcmp(only_run_test, "us*f") == 0)) { |
| 34519 | int i, j; |
| 34520 | static char code[] = "{\n\ |
| 34521 | unsigned short a = p1;\n\ |
| 34522 | float b = p2;\n\ |
| 34523 | return a * b;\n\ |
| 34524 | }"; |
| 34525 | |
| 34526 | unsigned short (*proc)(unsigned short a, float b); |
| 34527 | cod_parse_context context = new_cod_parse_context(); |
| 34528 | int dumped = 0; |
| 34529 | |
| 34530 | cod_code gen_code; |
| 34531 | |
| 34532 | /* test for unsigned short * float */ |
| 34533 | if (verbose) printf("test for unsigned short * float"); |
| 34534 | |
| 34535 | cod_assoc_externs(context, externs); |
| 34536 | cod_parse_for_context(extern_string, context); |
| 34537 | |
| 34538 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, float p2)", |
| 34539 | context); |
| 34540 | gen_code = cod_code_gen(code, context); |
| 34541 | proc = (unsigned short (*)(unsigned short, float))(long)gen_code->func; |
| 34542 | |
| 34543 | |
| 34544 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 34545 | unsigned short source1_us = src1us_vals[i]; |
| 34546 | for (j=0 ; j < sizeof(src2f_vals)/sizeof(src2f_vals[0]) ; j++) { |
| 34547 | float source2_f = src2f_vals[j]; |
| 34548 | double range = 0.000001 * (fabs((double)source1_us * (double)source2_f)); |
| 34549 | unsigned short expected_result; |
| 34550 | unsigned short result; |
| 34551 | |
| 34552 | |
| 34553 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 34554 | |
| 34555 | expected_result = (unsigned short) (source1_us * source2_f); |
| 34556 | |
| 34557 | result = proc(source1_us, source2_f); |
| 34558 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 34559 | range += 1.0; |
| 34560 | if ((result > (expected_result + range)) || (result < (expected_result - range))) { |
| 34561 | printf("Failed unsigned short * float test, expected %u, got %u, for %u * %g\n", |
| 34562 | expected_result, result, source1_us, source2_f); |
| 34563 | if (dumped == 0) cod_dump(gen_code); |
| 34564 | failed++; |
| 34565 | dumped++; |
| 34566 | } |
| 34567 | } |
| 34568 | } |
| 34569 | if (verbose) printf(" done\n"); |
| 34570 | cod_free_parse_context(context); |
| 34571 | cod_code_free(gen_code); |
| 34572 | } |
| 34573 | if ((only_run_test == NULL((void*)0)) || |
| 34574 | (strcmp(only_run_test, "us*d") == 0)) { |
| 34575 | int i, j; |
| 34576 | static char code[] = "{\n\ |
| 34577 | unsigned short a = p1;\n\ |
| 34578 | double b = p2;\n\ |
| 34579 | return a * b;\n\ |
| 34580 | }"; |
| 34581 | |
| 34582 | unsigned short (*proc)(unsigned short a, double b); |
| 34583 | cod_parse_context context = new_cod_parse_context(); |
| 34584 | int dumped = 0; |
| 34585 | |
| 34586 | cod_code gen_code; |
| 34587 | |
| 34588 | /* test for unsigned short * double */ |
| 34589 | if (verbose) printf("test for unsigned short * double"); |
| 34590 | |
| 34591 | cod_assoc_externs(context, externs); |
| 34592 | cod_parse_for_context(extern_string, context); |
| 34593 | |
| 34594 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, double p2)", |
| 34595 | context); |
| 34596 | gen_code = cod_code_gen(code, context); |
| 34597 | proc = (unsigned short (*)(unsigned short, double))(long)gen_code->func; |
| 34598 | |
| 34599 | |
| 34600 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 34601 | unsigned short source1_us = src1us_vals[i]; |
| 34602 | for (j=0 ; j < sizeof(src2d_vals)/sizeof(src2d_vals[0]) ; j++) { |
| 34603 | double source2_d = src2d_vals[j]; |
| 34604 | |
| 34605 | unsigned short expected_result; |
| 34606 | unsigned short result; |
| 34607 | |
| 34608 | |
| 34609 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 34610 | |
| 34611 | expected_result = (unsigned short) (source1_us * source2_d); |
| 34612 | |
| 34613 | result = proc(source1_us, source2_d); |
| 34614 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 34615 | if (expected_result != result) { |
| 34616 | printf("Failed unsigned short * double test, expected %u, got %u, for %u * %g\n", |
| 34617 | expected_result, result, source1_us, source2_d); |
| 34618 | if (dumped == 0) cod_dump(gen_code); |
| 34619 | failed++; |
| 34620 | dumped++; |
| 34621 | } |
| 34622 | } |
| 34623 | } |
| 34624 | if (verbose) printf(" done\n"); |
| 34625 | cod_free_parse_context(context); |
| 34626 | cod_code_free(gen_code); |
| 34627 | } |
| 34628 | } |
| 34629 | void mult_i_tests() |
| 34630 | { |
| 34631 | if ((only_run_test == NULL((void*)0)) || |
| 34632 | (strcmp(only_run_test, "i*c") == 0)) { |
| 34633 | int i, j; |
| 34634 | static char code[] = "{\n\ |
| 34635 | int a = p1;\n\ |
| 34636 | signed char b = p2;\n\ |
| 34637 | return a * b;\n\ |
| 34638 | }"; |
| 34639 | |
| 34640 | int (*proc)(int a, signed char b); |
| 34641 | cod_parse_context context = new_cod_parse_context(); |
| 34642 | int dumped = 0; |
| 34643 | |
| 34644 | cod_code gen_code; |
| 34645 | |
| 34646 | /* test for int * signed char */ |
| 34647 | if (verbose) printf("test for int * signed char"); |
| 34648 | |
| 34649 | cod_assoc_externs(context, externs); |
| 34650 | cod_parse_for_context(extern_string, context); |
| 34651 | |
| 34652 | cod_subroutine_declaration("int proc(int p1, signed char p2)", |
| 34653 | context); |
| 34654 | gen_code = cod_code_gen(code, context); |
| 34655 | proc = (int (*)(int, signed char))(long)gen_code->func; |
| 34656 | |
| 34657 | |
| 34658 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 34659 | int source1_i = src1i_vals[i]; |
| 34660 | for (j=0 ; j < sizeof(src2c_vals)/sizeof(src2c_vals[0]) ; j++) { |
| 34661 | signed char source2_c = src2c_vals[j]; |
| 34662 | |
| 34663 | int expected_result; |
| 34664 | int result; |
| 34665 | |
| 34666 | |
| 34667 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 34668 | |
| 34669 | expected_result = (int) (source1_i * source2_c); |
| 34670 | |
| 34671 | result = proc(source1_i, source2_c); |
| 34672 | if (expected_result != result) { |
| 34673 | printf("Failed int * signed char test, expected %d, got %d, for %d * %d\n", |
| 34674 | expected_result, result, source1_i, source2_c); |
| 34675 | if (dumped == 0) cod_dump(gen_code); |
| 34676 | failed++; |
| 34677 | dumped++; |
| 34678 | } |
| 34679 | } |
| 34680 | } |
| 34681 | if (verbose) printf(" done\n"); |
| 34682 | cod_free_parse_context(context); |
| 34683 | cod_code_free(gen_code); |
| 34684 | } |
| 34685 | if ((only_run_test == NULL((void*)0)) || |
| 34686 | (strcmp(only_run_test, "i*uc") == 0)) { |
| 34687 | int i, j; |
| 34688 | static char code[] = "{\n\ |
| 34689 | int a = p1;\n\ |
| 34690 | unsigned char b = p2;\n\ |
| 34691 | return a * b;\n\ |
| 34692 | }"; |
| 34693 | |
| 34694 | int (*proc)(int a, unsigned char b); |
| 34695 | cod_parse_context context = new_cod_parse_context(); |
| 34696 | int dumped = 0; |
| 34697 | |
| 34698 | cod_code gen_code; |
| 34699 | |
| 34700 | /* test for int * unsigned char */ |
| 34701 | if (verbose) printf("test for int * unsigned char"); |
| 34702 | |
| 34703 | cod_assoc_externs(context, externs); |
| 34704 | cod_parse_for_context(extern_string, context); |
| 34705 | |
| 34706 | cod_subroutine_declaration("int proc(int p1, unsigned char p2)", |
| 34707 | context); |
| 34708 | gen_code = cod_code_gen(code, context); |
| 34709 | proc = (int (*)(int, unsigned char))(long)gen_code->func; |
| 34710 | |
| 34711 | |
| 34712 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 34713 | int source1_i = src1i_vals[i]; |
| 34714 | for (j=0 ; j < sizeof(src2uc_vals)/sizeof(src2uc_vals[0]) ; j++) { |
| 34715 | unsigned char source2_uc = src2uc_vals[j]; |
| 34716 | |
| 34717 | int expected_result; |
| 34718 | int result; |
| 34719 | |
| 34720 | |
| 34721 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 34722 | |
| 34723 | expected_result = (int) (source1_i * source2_uc); |
| 34724 | |
| 34725 | result = proc(source1_i, source2_uc); |
| 34726 | if (expected_result != result) { |
| 34727 | printf("Failed int * unsigned char test, expected %d, got %d, for %d * %u\n", |
| 34728 | expected_result, result, source1_i, source2_uc); |
| 34729 | if (dumped == 0) cod_dump(gen_code); |
| 34730 | failed++; |
| 34731 | dumped++; |
| 34732 | } |
| 34733 | } |
| 34734 | } |
| 34735 | if (verbose) printf(" done\n"); |
| 34736 | cod_free_parse_context(context); |
| 34737 | cod_code_free(gen_code); |
| 34738 | } |
| 34739 | if ((only_run_test == NULL((void*)0)) || |
| 34740 | (strcmp(only_run_test, "i*s") == 0)) { |
| 34741 | int i, j; |
| 34742 | static char code[] = "{\n\ |
| 34743 | int a = p1;\n\ |
| 34744 | short b = p2;\n\ |
| 34745 | return a * b;\n\ |
| 34746 | }"; |
| 34747 | |
| 34748 | int (*proc)(int a, short b); |
| 34749 | cod_parse_context context = new_cod_parse_context(); |
| 34750 | int dumped = 0; |
| 34751 | |
| 34752 | cod_code gen_code; |
| 34753 | |
| 34754 | /* test for int * short */ |
| 34755 | if (verbose) printf("test for int * short"); |
| 34756 | |
| 34757 | cod_assoc_externs(context, externs); |
| 34758 | cod_parse_for_context(extern_string, context); |
| 34759 | |
| 34760 | cod_subroutine_declaration("int proc(int p1, short p2)", |
| 34761 | context); |
| 34762 | gen_code = cod_code_gen(code, context); |
| 34763 | proc = (int (*)(int, short))(long)gen_code->func; |
| 34764 | |
| 34765 | |
| 34766 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 34767 | int source1_i = src1i_vals[i]; |
| 34768 | for (j=0 ; j < sizeof(src2s_vals)/sizeof(src2s_vals[0]) ; j++) { |
| 34769 | short source2_s = src2s_vals[j]; |
| 34770 | |
| 34771 | int expected_result; |
| 34772 | int result; |
| 34773 | |
| 34774 | |
| 34775 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 34776 | |
| 34777 | expected_result = (int) (source1_i * source2_s); |
| 34778 | |
| 34779 | result = proc(source1_i, source2_s); |
| 34780 | if (expected_result != result) { |
| 34781 | printf("Failed int * short test, expected %d, got %d, for %d * %d\n", |
| 34782 | expected_result, result, source1_i, source2_s); |
| 34783 | if (dumped == 0) cod_dump(gen_code); |
| 34784 | failed++; |
| 34785 | dumped++; |
| 34786 | } |
| 34787 | } |
| 34788 | } |
| 34789 | if (verbose) printf(" done\n"); |
| 34790 | cod_free_parse_context(context); |
| 34791 | cod_code_free(gen_code); |
| 34792 | } |
| 34793 | if ((only_run_test == NULL((void*)0)) || |
| 34794 | (strcmp(only_run_test, "i*us") == 0)) { |
| 34795 | int i, j; |
| 34796 | static char code[] = "{\n\ |
| 34797 | int a = p1;\n\ |
| 34798 | unsigned short b = p2;\n\ |
| 34799 | return a * b;\n\ |
| 34800 | }"; |
| 34801 | |
| 34802 | int (*proc)(int a, unsigned short b); |
| 34803 | cod_parse_context context = new_cod_parse_context(); |
| 34804 | int dumped = 0; |
| 34805 | |
| 34806 | cod_code gen_code; |
| 34807 | |
| 34808 | /* test for int * unsigned short */ |
| 34809 | if (verbose) printf("test for int * unsigned short"); |
| 34810 | |
| 34811 | cod_assoc_externs(context, externs); |
| 34812 | cod_parse_for_context(extern_string, context); |
| 34813 | |
| 34814 | cod_subroutine_declaration("int proc(int p1, unsigned short p2)", |
| 34815 | context); |
| 34816 | gen_code = cod_code_gen(code, context); |
| 34817 | proc = (int (*)(int, unsigned short))(long)gen_code->func; |
| 34818 | |
| 34819 | |
| 34820 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 34821 | int source1_i = src1i_vals[i]; |
| 34822 | for (j=0 ; j < sizeof(src2us_vals)/sizeof(src2us_vals[0]) ; j++) { |
| 34823 | unsigned short source2_us = src2us_vals[j]; |
| 34824 | |
| 34825 | int expected_result; |
| 34826 | int result; |
| 34827 | |
| 34828 | |
| 34829 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 34830 | |
| 34831 | expected_result = (int) (source1_i * source2_us); |
| 34832 | |
| 34833 | result = proc(source1_i, source2_us); |
| 34834 | if (expected_result != result) { |
| 34835 | printf("Failed int * unsigned short test, expected %d, got %d, for %d * %u\n", |
| 34836 | expected_result, result, source1_i, source2_us); |
| 34837 | if (dumped == 0) cod_dump(gen_code); |
| 34838 | failed++; |
| 34839 | dumped++; |
| 34840 | } |
| 34841 | } |
| 34842 | } |
| 34843 | if (verbose) printf(" done\n"); |
| 34844 | cod_free_parse_context(context); |
| 34845 | cod_code_free(gen_code); |
| 34846 | } |
| 34847 | if ((only_run_test == NULL((void*)0)) || |
| 34848 | (strcmp(only_run_test, "i*i") == 0)) { |
| 34849 | int i, j; |
| 34850 | static char code[] = "{\n\ |
| 34851 | int a = p1;\n\ |
| 34852 | int b = p2;\n\ |
| 34853 | return a * b;\n\ |
| 34854 | }"; |
| 34855 | |
| 34856 | int (*proc)(int a, int b); |
| 34857 | cod_parse_context context = new_cod_parse_context(); |
| 34858 | int dumped = 0; |
| 34859 | |
| 34860 | cod_code gen_code; |
| 34861 | |
| 34862 | /* test for int * int */ |
| 34863 | if (verbose) printf("test for int * int"); |
| 34864 | |
| 34865 | cod_assoc_externs(context, externs); |
| 34866 | cod_parse_for_context(extern_string, context); |
| 34867 | |
| 34868 | cod_subroutine_declaration("int proc(int p1, int p2)", |
| 34869 | context); |
| 34870 | gen_code = cod_code_gen(code, context); |
| 34871 | proc = (int (*)(int, int))(long)gen_code->func; |
| 34872 | |
| 34873 | |
| 34874 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 34875 | int source1_i = src1i_vals[i]; |
| 34876 | for (j=0 ; j < sizeof(src2i_vals)/sizeof(src2i_vals[0]) ; j++) { |
| 34877 | int source2_i = src2i_vals[j]; |
| 34878 | |
| 34879 | int expected_result; |
| 34880 | int result; |
| 34881 | |
| 34882 | |
| 34883 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 34884 | |
| 34885 | expected_result = (int) (source1_i * source2_i); |
| 34886 | |
| 34887 | result = proc(source1_i, source2_i); |
| 34888 | if (expected_result != result) { |
| 34889 | printf("Failed int * int test, expected %d, got %d, for %d * %d\n", |
| 34890 | expected_result, result, source1_i, source2_i); |
| 34891 | if (dumped == 0) cod_dump(gen_code); |
| 34892 | failed++; |
| 34893 | dumped++; |
| 34894 | } |
| 34895 | } |
| 34896 | } |
| 34897 | if (verbose) printf(" done\n"); |
| 34898 | cod_free_parse_context(context); |
| 34899 | cod_code_free(gen_code); |
| 34900 | } |
| 34901 | if ((only_run_test == NULL((void*)0)) || |
| 34902 | (strcmp(only_run_test, "i*u") == 0)) { |
| 34903 | int i, j; |
| 34904 | static char code[] = "{\n\ |
| 34905 | int a = p1;\n\ |
| 34906 | unsigned int b = p2;\n\ |
| 34907 | return a * b;\n\ |
| 34908 | }"; |
| 34909 | |
| 34910 | int (*proc)(int a, unsigned int b); |
| 34911 | cod_parse_context context = new_cod_parse_context(); |
| 34912 | int dumped = 0; |
| 34913 | |
| 34914 | cod_code gen_code; |
| 34915 | |
| 34916 | /* test for int * unsigned int */ |
| 34917 | if (verbose) printf("test for int * unsigned int"); |
| 34918 | |
| 34919 | cod_assoc_externs(context, externs); |
| 34920 | cod_parse_for_context(extern_string, context); |
| 34921 | |
| 34922 | cod_subroutine_declaration("int proc(int p1, unsigned int p2)", |
| 34923 | context); |
| 34924 | gen_code = cod_code_gen(code, context); |
| 34925 | proc = (int (*)(int, unsigned int))(long)gen_code->func; |
| 34926 | |
| 34927 | |
| 34928 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 34929 | int source1_i = src1i_vals[i]; |
| 34930 | for (j=0 ; j < sizeof(src2u_vals)/sizeof(src2u_vals[0]) ; j++) { |
| 34931 | unsigned int source2_u = src2u_vals[j]; |
| 34932 | |
| 34933 | int expected_result; |
| 34934 | int result; |
| 34935 | |
| 34936 | |
| 34937 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 34938 | |
| 34939 | expected_result = (int) (source1_i * source2_u); |
| 34940 | |
| 34941 | result = proc(source1_i, source2_u); |
| 34942 | if (expected_result != result) { |
| 34943 | printf("Failed int * unsigned int test, expected %d, got %d, for %d * %u\n", |
| 34944 | expected_result, result, source1_i, source2_u); |
| 34945 | if (dumped == 0) cod_dump(gen_code); |
| 34946 | failed++; |
| 34947 | dumped++; |
| 34948 | } |
| 34949 | } |
| 34950 | } |
| 34951 | if (verbose) printf(" done\n"); |
| 34952 | cod_free_parse_context(context); |
| 34953 | cod_code_free(gen_code); |
| 34954 | } |
| 34955 | if ((only_run_test == NULL((void*)0)) || |
| 34956 | (strcmp(only_run_test, "i*ul") == 0)) { |
| 34957 | int i, j; |
| 34958 | static char code[] = "{\n\ |
| 34959 | int a = p1;\n\ |
| 34960 | unsigned long b = p2;\n\ |
| 34961 | return a * b;\n\ |
| 34962 | }"; |
| 34963 | |
| 34964 | int (*proc)(int a, unsigned long b); |
| 34965 | cod_parse_context context = new_cod_parse_context(); |
| 34966 | int dumped = 0; |
| 34967 | |
| 34968 | cod_code gen_code; |
| 34969 | |
| 34970 | /* test for int * unsigned long */ |
| 34971 | if (verbose) printf("test for int * unsigned long"); |
| 34972 | |
| 34973 | cod_assoc_externs(context, externs); |
| 34974 | cod_parse_for_context(extern_string, context); |
| 34975 | |
| 34976 | cod_subroutine_declaration("int proc(int p1, unsigned long p2)", |
| 34977 | context); |
| 34978 | gen_code = cod_code_gen(code, context); |
| 34979 | proc = (int (*)(int, unsigned long))(long)gen_code->func; |
| 34980 | |
| 34981 | |
| 34982 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 34983 | int source1_i = src1i_vals[i]; |
| 34984 | for (j=0 ; j < sizeof(src2ul_vals)/sizeof(src2ul_vals[0]) ; j++) { |
| 34985 | unsigned long source2_ul = src2ul_vals[j]; |
| 34986 | |
| 34987 | int expected_result; |
| 34988 | int result; |
| 34989 | |
| 34990 | |
| 34991 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 34992 | |
| 34993 | expected_result = (int) (source1_i * source2_ul); |
| 34994 | |
| 34995 | result = proc(source1_i, source2_ul); |
| 34996 | if (expected_result != result) { |
| 34997 | printf("Failed int * unsigned long test, expected %d, got %d, for %d * %lu\n", |
| 34998 | expected_result, result, source1_i, source2_ul); |
| 34999 | if (dumped == 0) cod_dump(gen_code); |
| 35000 | failed++; |
| 35001 | dumped++; |
| 35002 | } |
| 35003 | } |
| 35004 | } |
| 35005 | if (verbose) printf(" done\n"); |
| 35006 | cod_free_parse_context(context); |
| 35007 | cod_code_free(gen_code); |
| 35008 | } |
| 35009 | if ((only_run_test == NULL((void*)0)) || |
| 35010 | (strcmp(only_run_test, "i*l") == 0)) { |
| 35011 | int i, j; |
| 35012 | static char code[] = "{\n\ |
| 35013 | int a = p1;\n\ |
| 35014 | long b = p2;\n\ |
| 35015 | return a * b;\n\ |
| 35016 | }"; |
| 35017 | |
| 35018 | int (*proc)(int a, long b); |
| 35019 | cod_parse_context context = new_cod_parse_context(); |
| 35020 | int dumped = 0; |
| 35021 | |
| 35022 | cod_code gen_code; |
| 35023 | |
| 35024 | /* test for int * long */ |
| 35025 | if (verbose) printf("test for int * long"); |
| 35026 | |
| 35027 | cod_assoc_externs(context, externs); |
| 35028 | cod_parse_for_context(extern_string, context); |
| 35029 | |
| 35030 | cod_subroutine_declaration("int proc(int p1, long p2)", |
| 35031 | context); |
| 35032 | gen_code = cod_code_gen(code, context); |
| 35033 | proc = (int (*)(int, long))(long)gen_code->func; |
| 35034 | |
| 35035 | |
| 35036 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 35037 | int source1_i = src1i_vals[i]; |
| 35038 | for (j=0 ; j < sizeof(src2l_vals)/sizeof(src2l_vals[0]) ; j++) { |
| 35039 | long source2_l = src2l_vals[j]; |
| 35040 | |
| 35041 | int expected_result; |
| 35042 | int result; |
| 35043 | |
| 35044 | |
| 35045 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 35046 | |
| 35047 | expected_result = (int) (source1_i * source2_l); |
| 35048 | |
| 35049 | result = proc(source1_i, source2_l); |
| 35050 | if (expected_result != result) { |
| 35051 | printf("Failed int * long test, expected %d, got %d, for %d * %ld\n", |
| 35052 | expected_result, result, source1_i, source2_l); |
| 35053 | if (dumped == 0) cod_dump(gen_code); |
| 35054 | failed++; |
| 35055 | dumped++; |
| 35056 | } |
| 35057 | } |
| 35058 | } |
| 35059 | if (verbose) printf(" done\n"); |
| 35060 | cod_free_parse_context(context); |
| 35061 | cod_code_free(gen_code); |
| 35062 | } |
| 35063 | if ((only_run_test == NULL((void*)0)) || |
| 35064 | (strcmp(only_run_test, "i*f") == 0)) { |
| 35065 | int i, j; |
| 35066 | static char code[] = "{\n\ |
| 35067 | int a = p1;\n\ |
| 35068 | float b = p2;\n\ |
| 35069 | return a * b;\n\ |
| 35070 | }"; |
| 35071 | |
| 35072 | int (*proc)(int a, float b); |
| 35073 | cod_parse_context context = new_cod_parse_context(); |
| 35074 | int dumped = 0; |
| 35075 | |
| 35076 | cod_code gen_code; |
| 35077 | |
| 35078 | /* test for int * float */ |
| 35079 | if (verbose) printf("test for int * float"); |
| 35080 | |
| 35081 | cod_assoc_externs(context, externs); |
| 35082 | cod_parse_for_context(extern_string, context); |
| 35083 | |
| 35084 | cod_subroutine_declaration("int proc(int p1, float p2)", |
| 35085 | context); |
| 35086 | gen_code = cod_code_gen(code, context); |
| 35087 | proc = (int (*)(int, float))(long)gen_code->func; |
| 35088 | |
| 35089 | |
| 35090 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 35091 | int source1_i = src1i_vals[i]; |
| 35092 | for (j=0 ; j < sizeof(src2f_vals)/sizeof(src2f_vals[0]) ; j++) { |
| 35093 | float source2_f = src2f_vals[j]; |
| 35094 | double range = 0.000001 * (fabs((double)source1_i * (double)source2_f)); |
| 35095 | int expected_result; |
| 35096 | int result; |
| 35097 | |
| 35098 | |
| 35099 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 35100 | |
| 35101 | expected_result = (int) (source1_i * source2_f); |
| 35102 | |
| 35103 | result = proc(source1_i, source2_f); |
| 35104 | range += 1.0; |
| 35105 | if ((result > (expected_result + range)) || (result < (expected_result - range))) { |
| 35106 | printf("Failed int * float test, expected %d, got %d, for %d * %g\n", |
| 35107 | expected_result, result, source1_i, source2_f); |
| 35108 | if (dumped == 0) cod_dump(gen_code); |
| 35109 | failed++; |
| 35110 | dumped++; |
| 35111 | } |
| 35112 | } |
| 35113 | } |
| 35114 | if (verbose) printf(" done\n"); |
| 35115 | cod_free_parse_context(context); |
| 35116 | cod_code_free(gen_code); |
| 35117 | } |
| 35118 | if ((only_run_test == NULL((void*)0)) || |
| 35119 | (strcmp(only_run_test, "i*d") == 0)) { |
| 35120 | int i, j; |
| 35121 | static char code[] = "{\n\ |
| 35122 | int a = p1;\n\ |
| 35123 | double b = p2;\n\ |
| 35124 | return a * b;\n\ |
| 35125 | }"; |
| 35126 | |
| 35127 | int (*proc)(int a, double b); |
| 35128 | cod_parse_context context = new_cod_parse_context(); |
| 35129 | int dumped = 0; |
| 35130 | |
| 35131 | cod_code gen_code; |
| 35132 | |
| 35133 | /* test for int * double */ |
| 35134 | if (verbose) printf("test for int * double"); |
| 35135 | |
| 35136 | cod_assoc_externs(context, externs); |
| 35137 | cod_parse_for_context(extern_string, context); |
| 35138 | |
| 35139 | cod_subroutine_declaration("int proc(int p1, double p2)", |
| 35140 | context); |
| 35141 | gen_code = cod_code_gen(code, context); |
| 35142 | proc = (int (*)(int, double))(long)gen_code->func; |
| 35143 | |
| 35144 | |
| 35145 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 35146 | int source1_i = src1i_vals[i]; |
| 35147 | for (j=0 ; j < sizeof(src2d_vals)/sizeof(src2d_vals[0]) ; j++) { |
| 35148 | double source2_d = src2d_vals[j]; |
| 35149 | |
| 35150 | int expected_result; |
| 35151 | int result; |
| 35152 | |
| 35153 | |
| 35154 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 35155 | |
| 35156 | expected_result = (int) (source1_i * source2_d); |
| 35157 | |
| 35158 | result = proc(source1_i, source2_d); |
| 35159 | if (expected_result != result) { |
| 35160 | printf("Failed int * double test, expected %d, got %d, for %d * %g\n", |
| 35161 | expected_result, result, source1_i, source2_d); |
| 35162 | if (dumped == 0) cod_dump(gen_code); |
| 35163 | failed++; |
| 35164 | dumped++; |
| 35165 | } |
| 35166 | } |
| 35167 | } |
| 35168 | if (verbose) printf(" done\n"); |
| 35169 | cod_free_parse_context(context); |
| 35170 | cod_code_free(gen_code); |
| 35171 | } |
| 35172 | } |
| 35173 | void mult_u_tests() |
| 35174 | { |
| 35175 | if ((only_run_test == NULL((void*)0)) || |
| 35176 | (strcmp(only_run_test, "u*c") == 0)) { |
| 35177 | int i, j; |
| 35178 | static char code[] = "{\n\ |
| 35179 | unsigned int a = p1;\n\ |
| 35180 | signed char b = p2;\n\ |
| 35181 | return a * b;\n\ |
| 35182 | }"; |
| 35183 | |
| 35184 | unsigned int (*proc)(unsigned int a, signed char b); |
| 35185 | cod_parse_context context = new_cod_parse_context(); |
| 35186 | int dumped = 0; |
| 35187 | |
| 35188 | cod_code gen_code; |
| 35189 | |
| 35190 | /* test for unsigned int * signed char */ |
| 35191 | if (verbose) printf("test for unsigned int * signed char"); |
| 35192 | |
| 35193 | cod_assoc_externs(context, externs); |
| 35194 | cod_parse_for_context(extern_string, context); |
| 35195 | |
| 35196 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, signed char p2)", |
| 35197 | context); |
| 35198 | gen_code = cod_code_gen(code, context); |
| 35199 | proc = (unsigned int (*)(unsigned int, signed char))(long)gen_code->func; |
| 35200 | |
| 35201 | |
| 35202 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 35203 | unsigned int source1_u = src1u_vals[i]; |
| 35204 | for (j=0 ; j < sizeof(src2c_vals)/sizeof(src2c_vals[0]) ; j++) { |
| 35205 | signed char source2_c = src2c_vals[j]; |
| 35206 | |
| 35207 | unsigned int expected_result; |
| 35208 | unsigned int result; |
| 35209 | |
| 35210 | |
| 35211 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 35212 | |
| 35213 | expected_result = (unsigned int) (source1_u * source2_c); |
| 35214 | |
| 35215 | result = proc(source1_u, source2_c); |
| 35216 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 35217 | if (expected_result != result) { |
| 35218 | printf("Failed unsigned int * signed char test, expected %u, got %u, for %u * %d\n", |
| 35219 | expected_result, result, source1_u, source2_c); |
| 35220 | if (dumped == 0) cod_dump(gen_code); |
| 35221 | failed++; |
| 35222 | dumped++; |
| 35223 | } |
| 35224 | } |
| 35225 | } |
| 35226 | if (verbose) printf(" done\n"); |
| 35227 | cod_free_parse_context(context); |
| 35228 | cod_code_free(gen_code); |
| 35229 | } |
| 35230 | if ((only_run_test == NULL((void*)0)) || |
| 35231 | (strcmp(only_run_test, "u*uc") == 0)) { |
| 35232 | int i, j; |
| 35233 | static char code[] = "{\n\ |
| 35234 | unsigned int a = p1;\n\ |
| 35235 | unsigned char b = p2;\n\ |
| 35236 | return a * b;\n\ |
| 35237 | }"; |
| 35238 | |
| 35239 | unsigned int (*proc)(unsigned int a, unsigned char b); |
| 35240 | cod_parse_context context = new_cod_parse_context(); |
| 35241 | int dumped = 0; |
| 35242 | |
| 35243 | cod_code gen_code; |
| 35244 | |
| 35245 | /* test for unsigned int * unsigned char */ |
| 35246 | if (verbose) printf("test for unsigned int * unsigned char"); |
| 35247 | |
| 35248 | cod_assoc_externs(context, externs); |
| 35249 | cod_parse_for_context(extern_string, context); |
| 35250 | |
| 35251 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, unsigned char p2)", |
| 35252 | context); |
| 35253 | gen_code = cod_code_gen(code, context); |
| 35254 | proc = (unsigned int (*)(unsigned int, unsigned char))(long)gen_code->func; |
| 35255 | |
| 35256 | |
| 35257 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 35258 | unsigned int source1_u = src1u_vals[i]; |
| 35259 | for (j=0 ; j < sizeof(src2uc_vals)/sizeof(src2uc_vals[0]) ; j++) { |
| 35260 | unsigned char source2_uc = src2uc_vals[j]; |
| 35261 | |
| 35262 | unsigned int expected_result; |
| 35263 | unsigned int result; |
| 35264 | |
| 35265 | |
| 35266 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 35267 | |
| 35268 | expected_result = (unsigned int) (source1_u * source2_uc); |
| 35269 | |
| 35270 | result = proc(source1_u, source2_uc); |
| 35271 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 35272 | if (expected_result != result) { |
| 35273 | printf("Failed unsigned int * unsigned char test, expected %u, got %u, for %u * %u\n", |
| 35274 | expected_result, result, source1_u, source2_uc); |
| 35275 | if (dumped == 0) cod_dump(gen_code); |
| 35276 | failed++; |
| 35277 | dumped++; |
| 35278 | } |
| 35279 | } |
| 35280 | } |
| 35281 | if (verbose) printf(" done\n"); |
| 35282 | cod_free_parse_context(context); |
| 35283 | cod_code_free(gen_code); |
| 35284 | } |
| 35285 | if ((only_run_test == NULL((void*)0)) || |
| 35286 | (strcmp(only_run_test, "u*s") == 0)) { |
| 35287 | int i, j; |
| 35288 | static char code[] = "{\n\ |
| 35289 | unsigned int a = p1;\n\ |
| 35290 | short b = p2;\n\ |
| 35291 | return a * b;\n\ |
| 35292 | }"; |
| 35293 | |
| 35294 | unsigned int (*proc)(unsigned int a, short b); |
| 35295 | cod_parse_context context = new_cod_parse_context(); |
| 35296 | int dumped = 0; |
| 35297 | |
| 35298 | cod_code gen_code; |
| 35299 | |
| 35300 | /* test for unsigned int * short */ |
| 35301 | if (verbose) printf("test for unsigned int * short"); |
| 35302 | |
| 35303 | cod_assoc_externs(context, externs); |
| 35304 | cod_parse_for_context(extern_string, context); |
| 35305 | |
| 35306 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, short p2)", |
| 35307 | context); |
| 35308 | gen_code = cod_code_gen(code, context); |
| 35309 | proc = (unsigned int (*)(unsigned int, short))(long)gen_code->func; |
| 35310 | |
| 35311 | |
| 35312 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 35313 | unsigned int source1_u = src1u_vals[i]; |
| 35314 | for (j=0 ; j < sizeof(src2s_vals)/sizeof(src2s_vals[0]) ; j++) { |
| 35315 | short source2_s = src2s_vals[j]; |
| 35316 | |
| 35317 | unsigned int expected_result; |
| 35318 | unsigned int result; |
| 35319 | |
| 35320 | |
| 35321 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 35322 | |
| 35323 | expected_result = (unsigned int) (source1_u * source2_s); |
| 35324 | |
| 35325 | result = proc(source1_u, source2_s); |
| 35326 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 35327 | if (expected_result != result) { |
| 35328 | printf("Failed unsigned int * short test, expected %u, got %u, for %u * %d\n", |
| 35329 | expected_result, result, source1_u, source2_s); |
| 35330 | if (dumped == 0) cod_dump(gen_code); |
| 35331 | failed++; |
| 35332 | dumped++; |
| 35333 | } |
| 35334 | } |
| 35335 | } |
| 35336 | if (verbose) printf(" done\n"); |
| 35337 | cod_free_parse_context(context); |
| 35338 | cod_code_free(gen_code); |
| 35339 | } |
| 35340 | if ((only_run_test == NULL((void*)0)) || |
| 35341 | (strcmp(only_run_test, "u*us") == 0)) { |
| 35342 | int i, j; |
| 35343 | static char code[] = "{\n\ |
| 35344 | unsigned int a = p1;\n\ |
| 35345 | unsigned short b = p2;\n\ |
| 35346 | return a * b;\n\ |
| 35347 | }"; |
| 35348 | |
| 35349 | unsigned int (*proc)(unsigned int a, unsigned short b); |
| 35350 | cod_parse_context context = new_cod_parse_context(); |
| 35351 | int dumped = 0; |
| 35352 | |
| 35353 | cod_code gen_code; |
| 35354 | |
| 35355 | /* test for unsigned int * unsigned short */ |
| 35356 | if (verbose) printf("test for unsigned int * unsigned short"); |
| 35357 | |
| 35358 | cod_assoc_externs(context, externs); |
| 35359 | cod_parse_for_context(extern_string, context); |
| 35360 | |
| 35361 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, unsigned short p2)", |
| 35362 | context); |
| 35363 | gen_code = cod_code_gen(code, context); |
| 35364 | proc = (unsigned int (*)(unsigned int, unsigned short))(long)gen_code->func; |
| 35365 | |
| 35366 | |
| 35367 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 35368 | unsigned int source1_u = src1u_vals[i]; |
| 35369 | for (j=0 ; j < sizeof(src2us_vals)/sizeof(src2us_vals[0]) ; j++) { |
| 35370 | unsigned short source2_us = src2us_vals[j]; |
| 35371 | |
| 35372 | unsigned int expected_result; |
| 35373 | unsigned int result; |
| 35374 | |
| 35375 | |
| 35376 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 35377 | |
| 35378 | expected_result = (unsigned int) (source1_u * source2_us); |
| 35379 | |
| 35380 | result = proc(source1_u, source2_us); |
| 35381 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 35382 | if (expected_result != result) { |
| 35383 | printf("Failed unsigned int * unsigned short test, expected %u, got %u, for %u * %u\n", |
| 35384 | expected_result, result, source1_u, source2_us); |
| 35385 | if (dumped == 0) cod_dump(gen_code); |
| 35386 | failed++; |
| 35387 | dumped++; |
| 35388 | } |
| 35389 | } |
| 35390 | } |
| 35391 | if (verbose) printf(" done\n"); |
| 35392 | cod_free_parse_context(context); |
| 35393 | cod_code_free(gen_code); |
| 35394 | } |
| 35395 | if ((only_run_test == NULL((void*)0)) || |
| 35396 | (strcmp(only_run_test, "u*i") == 0)) { |
| 35397 | int i, j; |
| 35398 | static char code[] = "{\n\ |
| 35399 | unsigned int a = p1;\n\ |
| 35400 | int b = p2;\n\ |
| 35401 | return a * b;\n\ |
| 35402 | }"; |
| 35403 | |
| 35404 | unsigned int (*proc)(unsigned int a, int b); |
| 35405 | cod_parse_context context = new_cod_parse_context(); |
| 35406 | int dumped = 0; |
| 35407 | |
| 35408 | cod_code gen_code; |
| 35409 | |
| 35410 | /* test for unsigned int * int */ |
| 35411 | if (verbose) printf("test for unsigned int * int"); |
| 35412 | |
| 35413 | cod_assoc_externs(context, externs); |
| 35414 | cod_parse_for_context(extern_string, context); |
| 35415 | |
| 35416 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, int p2)", |
| 35417 | context); |
| 35418 | gen_code = cod_code_gen(code, context); |
| 35419 | proc = (unsigned int (*)(unsigned int, int))(long)gen_code->func; |
| 35420 | |
| 35421 | |
| 35422 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 35423 | unsigned int source1_u = src1u_vals[i]; |
| 35424 | for (j=0 ; j < sizeof(src2i_vals)/sizeof(src2i_vals[0]) ; j++) { |
| 35425 | int source2_i = src2i_vals[j]; |
| 35426 | |
| 35427 | unsigned int expected_result; |
| 35428 | unsigned int result; |
| 35429 | |
| 35430 | |
| 35431 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 35432 | |
| 35433 | expected_result = (unsigned int) (source1_u * source2_i); |
| 35434 | |
| 35435 | result = proc(source1_u, source2_i); |
| 35436 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 35437 | if (expected_result != result) { |
| 35438 | printf("Failed unsigned int * int test, expected %u, got %u, for %u * %d\n", |
| 35439 | expected_result, result, source1_u, source2_i); |
| 35440 | if (dumped == 0) cod_dump(gen_code); |
| 35441 | failed++; |
| 35442 | dumped++; |
| 35443 | } |
| 35444 | } |
| 35445 | } |
| 35446 | if (verbose) printf(" done\n"); |
| 35447 | cod_free_parse_context(context); |
| 35448 | cod_code_free(gen_code); |
| 35449 | } |
| 35450 | if ((only_run_test == NULL((void*)0)) || |
| 35451 | (strcmp(only_run_test, "u*u") == 0)) { |
| 35452 | int i, j; |
| 35453 | static char code[] = "{\n\ |
| 35454 | unsigned int a = p1;\n\ |
| 35455 | unsigned int b = p2;\n\ |
| 35456 | return a * b;\n\ |
| 35457 | }"; |
| 35458 | |
| 35459 | unsigned int (*proc)(unsigned int a, unsigned int b); |
| 35460 | cod_parse_context context = new_cod_parse_context(); |
| 35461 | int dumped = 0; |
| 35462 | |
| 35463 | cod_code gen_code; |
| 35464 | |
| 35465 | /* test for unsigned int * unsigned int */ |
| 35466 | if (verbose) printf("test for unsigned int * unsigned int"); |
| 35467 | |
| 35468 | cod_assoc_externs(context, externs); |
| 35469 | cod_parse_for_context(extern_string, context); |
| 35470 | |
| 35471 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, unsigned int p2)", |
| 35472 | context); |
| 35473 | gen_code = cod_code_gen(code, context); |
| 35474 | proc = (unsigned int (*)(unsigned int, unsigned int))(long)gen_code->func; |
| 35475 | |
| 35476 | |
| 35477 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 35478 | unsigned int source1_u = src1u_vals[i]; |
| 35479 | for (j=0 ; j < sizeof(src2u_vals)/sizeof(src2u_vals[0]) ; j++) { |
| 35480 | unsigned int source2_u = src2u_vals[j]; |
| 35481 | |
| 35482 | unsigned int expected_result; |
| 35483 | unsigned int result; |
| 35484 | |
| 35485 | |
| 35486 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 35487 | |
| 35488 | expected_result = (unsigned int) (source1_u * source2_u); |
| 35489 | |
| 35490 | result = proc(source1_u, source2_u); |
| 35491 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 35492 | if (expected_result != result) { |
| 35493 | printf("Failed unsigned int * unsigned int test, expected %u, got %u, for %u * %u\n", |
| 35494 | expected_result, result, source1_u, source2_u); |
| 35495 | if (dumped == 0) cod_dump(gen_code); |
| 35496 | failed++; |
| 35497 | dumped++; |
| 35498 | } |
| 35499 | } |
| 35500 | } |
| 35501 | if (verbose) printf(" done\n"); |
| 35502 | cod_free_parse_context(context); |
| 35503 | cod_code_free(gen_code); |
| 35504 | } |
| 35505 | if ((only_run_test == NULL((void*)0)) || |
| 35506 | (strcmp(only_run_test, "u*ul") == 0)) { |
| 35507 | int i, j; |
| 35508 | static char code[] = "{\n\ |
| 35509 | unsigned int a = p1;\n\ |
| 35510 | unsigned long b = p2;\n\ |
| 35511 | return a * b;\n\ |
| 35512 | }"; |
| 35513 | |
| 35514 | unsigned int (*proc)(unsigned int a, unsigned long b); |
| 35515 | cod_parse_context context = new_cod_parse_context(); |
| 35516 | int dumped = 0; |
| 35517 | |
| 35518 | cod_code gen_code; |
| 35519 | |
| 35520 | /* test for unsigned int * unsigned long */ |
| 35521 | if (verbose) printf("test for unsigned int * unsigned long"); |
| 35522 | |
| 35523 | cod_assoc_externs(context, externs); |
| 35524 | cod_parse_for_context(extern_string, context); |
| 35525 | |
| 35526 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, unsigned long p2)", |
| 35527 | context); |
| 35528 | gen_code = cod_code_gen(code, context); |
| 35529 | proc = (unsigned int (*)(unsigned int, unsigned long))(long)gen_code->func; |
| 35530 | |
| 35531 | |
| 35532 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 35533 | unsigned int source1_u = src1u_vals[i]; |
| 35534 | for (j=0 ; j < sizeof(src2ul_vals)/sizeof(src2ul_vals[0]) ; j++) { |
| 35535 | unsigned long source2_ul = src2ul_vals[j]; |
| 35536 | |
| 35537 | unsigned int expected_result; |
| 35538 | unsigned int result; |
| 35539 | |
| 35540 | |
| 35541 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 35542 | |
| 35543 | expected_result = (unsigned int) (source1_u * source2_ul); |
| 35544 | |
| 35545 | result = proc(source1_u, source2_ul); |
| 35546 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 35547 | if (expected_result != result) { |
| 35548 | printf("Failed unsigned int * unsigned long test, expected %u, got %u, for %u * %lu\n", |
| 35549 | expected_result, result, source1_u, source2_ul); |
| 35550 | if (dumped == 0) cod_dump(gen_code); |
| 35551 | failed++; |
| 35552 | dumped++; |
| 35553 | } |
| 35554 | } |
| 35555 | } |
| 35556 | if (verbose) printf(" done\n"); |
| 35557 | cod_free_parse_context(context); |
| 35558 | cod_code_free(gen_code); |
| 35559 | } |
| 35560 | if ((only_run_test == NULL((void*)0)) || |
| 35561 | (strcmp(only_run_test, "u*l") == 0)) { |
| 35562 | int i, j; |
| 35563 | static char code[] = "{\n\ |
| 35564 | unsigned int a = p1;\n\ |
| 35565 | long b = p2;\n\ |
| 35566 | return a * b;\n\ |
| 35567 | }"; |
| 35568 | |
| 35569 | unsigned int (*proc)(unsigned int a, long b); |
| 35570 | cod_parse_context context = new_cod_parse_context(); |
| 35571 | int dumped = 0; |
| 35572 | |
| 35573 | cod_code gen_code; |
| 35574 | |
| 35575 | /* test for unsigned int * long */ |
| 35576 | if (verbose) printf("test for unsigned int * long"); |
| 35577 | |
| 35578 | cod_assoc_externs(context, externs); |
| 35579 | cod_parse_for_context(extern_string, context); |
| 35580 | |
| 35581 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, long p2)", |
| 35582 | context); |
| 35583 | gen_code = cod_code_gen(code, context); |
| 35584 | proc = (unsigned int (*)(unsigned int, long))(long)gen_code->func; |
| 35585 | |
| 35586 | |
| 35587 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 35588 | unsigned int source1_u = src1u_vals[i]; |
| 35589 | for (j=0 ; j < sizeof(src2l_vals)/sizeof(src2l_vals[0]) ; j++) { |
| 35590 | long source2_l = src2l_vals[j]; |
| 35591 | |
| 35592 | unsigned int expected_result; |
| 35593 | unsigned int result; |
| 35594 | |
| 35595 | |
| 35596 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 35597 | |
| 35598 | expected_result = (unsigned int) (source1_u * source2_l); |
| 35599 | |
| 35600 | result = proc(source1_u, source2_l); |
| 35601 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 35602 | if (expected_result != result) { |
| 35603 | printf("Failed unsigned int * long test, expected %u, got %u, for %u * %ld\n", |
| 35604 | expected_result, result, source1_u, source2_l); |
| 35605 | if (dumped == 0) cod_dump(gen_code); |
| 35606 | failed++; |
| 35607 | dumped++; |
| 35608 | } |
| 35609 | } |
| 35610 | } |
| 35611 | if (verbose) printf(" done\n"); |
| 35612 | cod_free_parse_context(context); |
| 35613 | cod_code_free(gen_code); |
| 35614 | } |
| 35615 | if ((only_run_test == NULL((void*)0)) || |
| 35616 | (strcmp(only_run_test, "u*f") == 0)) { |
| 35617 | int i, j; |
| 35618 | static char code[] = "{\n\ |
| 35619 | unsigned int a = p1;\n\ |
| 35620 | float b = p2;\n\ |
| 35621 | return a * b;\n\ |
| 35622 | }"; |
| 35623 | |
| 35624 | unsigned int (*proc)(unsigned int a, float b); |
| 35625 | cod_parse_context context = new_cod_parse_context(); |
| 35626 | int dumped = 0; |
| 35627 | |
| 35628 | cod_code gen_code; |
| 35629 | |
| 35630 | /* test for unsigned int * float */ |
| 35631 | if (verbose) printf("test for unsigned int * float"); |
| 35632 | |
| 35633 | cod_assoc_externs(context, externs); |
| 35634 | cod_parse_for_context(extern_string, context); |
| 35635 | |
| 35636 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, float p2)", |
| 35637 | context); |
| 35638 | gen_code = cod_code_gen(code, context); |
| 35639 | proc = (unsigned int (*)(unsigned int, float))(long)gen_code->func; |
| 35640 | |
| 35641 | |
| 35642 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 35643 | unsigned int source1_u = src1u_vals[i]; |
| 35644 | for (j=0 ; j < sizeof(src2f_vals)/sizeof(src2f_vals[0]) ; j++) { |
| 35645 | float source2_f = src2f_vals[j]; |
| 35646 | double range = 0.000001 * (fabs((double)source1_u * (double)source2_f)); |
| 35647 | unsigned int expected_result; |
| 35648 | unsigned int result; |
| 35649 | |
| 35650 | |
| 35651 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 35652 | |
| 35653 | expected_result = (unsigned int) (source1_u * source2_f); |
| 35654 | |
| 35655 | result = proc(source1_u, source2_f); |
| 35656 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 35657 | range += 1.0; |
| 35658 | if ((result > (expected_result + range)) || (result < (expected_result - range))) { |
| 35659 | printf("Failed unsigned int * float test, expected %u, got %u, for %u * %g\n", |
| 35660 | expected_result, result, source1_u, source2_f); |
| 35661 | if (dumped == 0) cod_dump(gen_code); |
| 35662 | failed++; |
| 35663 | dumped++; |
| 35664 | } |
| 35665 | } |
| 35666 | } |
| 35667 | if (verbose) printf(" done\n"); |
| 35668 | cod_free_parse_context(context); |
| 35669 | cod_code_free(gen_code); |
| 35670 | } |
| 35671 | if ((only_run_test == NULL((void*)0)) || |
| 35672 | (strcmp(only_run_test, "u*d") == 0)) { |
| 35673 | int i, j; |
| 35674 | static char code[] = "{\n\ |
| 35675 | unsigned int a = p1;\n\ |
| 35676 | double b = p2;\n\ |
| 35677 | return a * b;\n\ |
| 35678 | }"; |
| 35679 | |
| 35680 | unsigned int (*proc)(unsigned int a, double b); |
| 35681 | cod_parse_context context = new_cod_parse_context(); |
| 35682 | int dumped = 0; |
| 35683 | |
| 35684 | cod_code gen_code; |
| 35685 | |
| 35686 | /* test for unsigned int * double */ |
| 35687 | if (verbose) printf("test for unsigned int * double"); |
| 35688 | |
| 35689 | cod_assoc_externs(context, externs); |
| 35690 | cod_parse_for_context(extern_string, context); |
| 35691 | |
| 35692 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, double p2)", |
| 35693 | context); |
| 35694 | gen_code = cod_code_gen(code, context); |
| 35695 | proc = (unsigned int (*)(unsigned int, double))(long)gen_code->func; |
| 35696 | |
| 35697 | |
| 35698 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 35699 | unsigned int source1_u = src1u_vals[i]; |
| 35700 | for (j=0 ; j < sizeof(src2d_vals)/sizeof(src2d_vals[0]) ; j++) { |
| 35701 | double source2_d = src2d_vals[j]; |
| 35702 | |
| 35703 | unsigned int expected_result; |
| 35704 | unsigned int result; |
| 35705 | |
| 35706 | |
| 35707 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 35708 | |
| 35709 | expected_result = (unsigned int) (source1_u * source2_d); |
| 35710 | |
| 35711 | result = proc(source1_u, source2_d); |
| 35712 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 35713 | if (expected_result != result) { |
| 35714 | printf("Failed unsigned int * double test, expected %u, got %u, for %u * %g\n", |
| 35715 | expected_result, result, source1_u, source2_d); |
| 35716 | if (dumped == 0) cod_dump(gen_code); |
| 35717 | failed++; |
| 35718 | dumped++; |
| 35719 | } |
| 35720 | } |
| 35721 | } |
| 35722 | if (verbose) printf(" done\n"); |
| 35723 | cod_free_parse_context(context); |
| 35724 | cod_code_free(gen_code); |
| 35725 | } |
| 35726 | } |
| 35727 | void mult_ul_tests() |
| 35728 | { |
| 35729 | if ((only_run_test == NULL((void*)0)) || |
| 35730 | (strcmp(only_run_test, "ul*c") == 0)) { |
| 35731 | int i, j; |
| 35732 | static char code[] = "{\n\ |
| 35733 | unsigned long a = p1;\n\ |
| 35734 | signed char b = p2;\n\ |
| 35735 | return a * b;\n\ |
| 35736 | }"; |
| 35737 | |
| 35738 | unsigned long (*proc)(unsigned long a, signed char b); |
| 35739 | cod_parse_context context = new_cod_parse_context(); |
| 35740 | int dumped = 0; |
| 35741 | |
| 35742 | cod_code gen_code; |
| 35743 | |
| 35744 | /* test for unsigned long * signed char */ |
| 35745 | if (verbose) printf("test for unsigned long * signed char"); |
| 35746 | |
| 35747 | cod_assoc_externs(context, externs); |
| 35748 | cod_parse_for_context(extern_string, context); |
| 35749 | |
| 35750 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, signed char p2)", |
| 35751 | context); |
| 35752 | gen_code = cod_code_gen(code, context); |
| 35753 | proc = (unsigned long (*)(unsigned long, signed char))(long)gen_code->func; |
| 35754 | |
| 35755 | |
| 35756 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 35757 | unsigned long source1_ul = src1ul_vals[i]; |
| 35758 | for (j=0 ; j < sizeof(src2c_vals)/sizeof(src2c_vals[0]) ; j++) { |
| 35759 | signed char source2_c = src2c_vals[j]; |
| 35760 | |
| 35761 | unsigned long expected_result; |
| 35762 | unsigned long result; |
| 35763 | |
| 35764 | |
| 35765 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 35766 | |
| 35767 | expected_result = (unsigned long) (source1_ul * source2_c); |
| 35768 | |
| 35769 | result = proc(source1_ul, source2_c); |
| 35770 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 35771 | if (expected_result != result) { |
| 35772 | printf("Failed unsigned long * signed char test, expected %lu, got %lu, for %lu * %d\n", |
| 35773 | expected_result, result, source1_ul, source2_c); |
| 35774 | if (dumped == 0) cod_dump(gen_code); |
| 35775 | failed++; |
| 35776 | dumped++; |
| 35777 | } |
| 35778 | } |
| 35779 | } |
| 35780 | if (verbose) printf(" done\n"); |
| 35781 | cod_free_parse_context(context); |
| 35782 | cod_code_free(gen_code); |
| 35783 | } |
| 35784 | if ((only_run_test == NULL((void*)0)) || |
| 35785 | (strcmp(only_run_test, "ul*uc") == 0)) { |
| 35786 | int i, j; |
| 35787 | static char code[] = "{\n\ |
| 35788 | unsigned long a = p1;\n\ |
| 35789 | unsigned char b = p2;\n\ |
| 35790 | return a * b;\n\ |
| 35791 | }"; |
| 35792 | |
| 35793 | unsigned long (*proc)(unsigned long a, unsigned char b); |
| 35794 | cod_parse_context context = new_cod_parse_context(); |
| 35795 | int dumped = 0; |
| 35796 | |
| 35797 | cod_code gen_code; |
| 35798 | |
| 35799 | /* test for unsigned long * unsigned char */ |
| 35800 | if (verbose) printf("test for unsigned long * unsigned char"); |
| 35801 | |
| 35802 | cod_assoc_externs(context, externs); |
| 35803 | cod_parse_for_context(extern_string, context); |
| 35804 | |
| 35805 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, unsigned char p2)", |
| 35806 | context); |
| 35807 | gen_code = cod_code_gen(code, context); |
| 35808 | proc = (unsigned long (*)(unsigned long, unsigned char))(long)gen_code->func; |
| 35809 | |
| 35810 | |
| 35811 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 35812 | unsigned long source1_ul = src1ul_vals[i]; |
| 35813 | for (j=0 ; j < sizeof(src2uc_vals)/sizeof(src2uc_vals[0]) ; j++) { |
| 35814 | unsigned char source2_uc = src2uc_vals[j]; |
| 35815 | |
| 35816 | unsigned long expected_result; |
| 35817 | unsigned long result; |
| 35818 | |
| 35819 | |
| 35820 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 35821 | |
| 35822 | expected_result = (unsigned long) (source1_ul * source2_uc); |
| 35823 | |
| 35824 | result = proc(source1_ul, source2_uc); |
| 35825 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 35826 | if (expected_result != result) { |
| 35827 | printf("Failed unsigned long * unsigned char test, expected %lu, got %lu, for %lu * %u\n", |
| 35828 | expected_result, result, source1_ul, source2_uc); |
| 35829 | if (dumped == 0) cod_dump(gen_code); |
| 35830 | failed++; |
| 35831 | dumped++; |
| 35832 | } |
| 35833 | } |
| 35834 | } |
| 35835 | if (verbose) printf(" done\n"); |
| 35836 | cod_free_parse_context(context); |
| 35837 | cod_code_free(gen_code); |
| 35838 | } |
| 35839 | if ((only_run_test == NULL((void*)0)) || |
| 35840 | (strcmp(only_run_test, "ul*s") == 0)) { |
| 35841 | int i, j; |
| 35842 | static char code[] = "{\n\ |
| 35843 | unsigned long a = p1;\n\ |
| 35844 | short b = p2;\n\ |
| 35845 | return a * b;\n\ |
| 35846 | }"; |
| 35847 | |
| 35848 | unsigned long (*proc)(unsigned long a, short b); |
| 35849 | cod_parse_context context = new_cod_parse_context(); |
| 35850 | int dumped = 0; |
| 35851 | |
| 35852 | cod_code gen_code; |
| 35853 | |
| 35854 | /* test for unsigned long * short */ |
| 35855 | if (verbose) printf("test for unsigned long * short"); |
| 35856 | |
| 35857 | cod_assoc_externs(context, externs); |
| 35858 | cod_parse_for_context(extern_string, context); |
| 35859 | |
| 35860 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, short p2)", |
| 35861 | context); |
| 35862 | gen_code = cod_code_gen(code, context); |
| 35863 | proc = (unsigned long (*)(unsigned long, short))(long)gen_code->func; |
| 35864 | |
| 35865 | |
| 35866 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 35867 | unsigned long source1_ul = src1ul_vals[i]; |
| 35868 | for (j=0 ; j < sizeof(src2s_vals)/sizeof(src2s_vals[0]) ; j++) { |
| 35869 | short source2_s = src2s_vals[j]; |
| 35870 | |
| 35871 | unsigned long expected_result; |
| 35872 | unsigned long result; |
| 35873 | |
| 35874 | |
| 35875 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 35876 | |
| 35877 | expected_result = (unsigned long) (source1_ul * source2_s); |
| 35878 | |
| 35879 | result = proc(source1_ul, source2_s); |
| 35880 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 35881 | if (expected_result != result) { |
| 35882 | printf("Failed unsigned long * short test, expected %lu, got %lu, for %lu * %d\n", |
| 35883 | expected_result, result, source1_ul, source2_s); |
| 35884 | if (dumped == 0) cod_dump(gen_code); |
| 35885 | failed++; |
| 35886 | dumped++; |
| 35887 | } |
| 35888 | } |
| 35889 | } |
| 35890 | if (verbose) printf(" done\n"); |
| 35891 | cod_free_parse_context(context); |
| 35892 | cod_code_free(gen_code); |
| 35893 | } |
| 35894 | if ((only_run_test == NULL((void*)0)) || |
| 35895 | (strcmp(only_run_test, "ul*us") == 0)) { |
| 35896 | int i, j; |
| 35897 | static char code[] = "{\n\ |
| 35898 | unsigned long a = p1;\n\ |
| 35899 | unsigned short b = p2;\n\ |
| 35900 | return a * b;\n\ |
| 35901 | }"; |
| 35902 | |
| 35903 | unsigned long (*proc)(unsigned long a, unsigned short b); |
| 35904 | cod_parse_context context = new_cod_parse_context(); |
| 35905 | int dumped = 0; |
| 35906 | |
| 35907 | cod_code gen_code; |
| 35908 | |
| 35909 | /* test for unsigned long * unsigned short */ |
| 35910 | if (verbose) printf("test for unsigned long * unsigned short"); |
| 35911 | |
| 35912 | cod_assoc_externs(context, externs); |
| 35913 | cod_parse_for_context(extern_string, context); |
| 35914 | |
| 35915 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, unsigned short p2)", |
| 35916 | context); |
| 35917 | gen_code = cod_code_gen(code, context); |
| 35918 | proc = (unsigned long (*)(unsigned long, unsigned short))(long)gen_code->func; |
| 35919 | |
| 35920 | |
| 35921 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 35922 | unsigned long source1_ul = src1ul_vals[i]; |
| 35923 | for (j=0 ; j < sizeof(src2us_vals)/sizeof(src2us_vals[0]) ; j++) { |
| 35924 | unsigned short source2_us = src2us_vals[j]; |
| 35925 | |
| 35926 | unsigned long expected_result; |
| 35927 | unsigned long result; |
| 35928 | |
| 35929 | |
| 35930 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 35931 | |
| 35932 | expected_result = (unsigned long) (source1_ul * source2_us); |
| 35933 | |
| 35934 | result = proc(source1_ul, source2_us); |
| 35935 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 35936 | if (expected_result != result) { |
| 35937 | printf("Failed unsigned long * unsigned short test, expected %lu, got %lu, for %lu * %u\n", |
| 35938 | expected_result, result, source1_ul, source2_us); |
| 35939 | if (dumped == 0) cod_dump(gen_code); |
| 35940 | failed++; |
| 35941 | dumped++; |
| 35942 | } |
| 35943 | } |
| 35944 | } |
| 35945 | if (verbose) printf(" done\n"); |
| 35946 | cod_free_parse_context(context); |
| 35947 | cod_code_free(gen_code); |
| 35948 | } |
| 35949 | if ((only_run_test == NULL((void*)0)) || |
| 35950 | (strcmp(only_run_test, "ul*i") == 0)) { |
| 35951 | int i, j; |
| 35952 | static char code[] = "{\n\ |
| 35953 | unsigned long a = p1;\n\ |
| 35954 | int b = p2;\n\ |
| 35955 | return a * b;\n\ |
| 35956 | }"; |
| 35957 | |
| 35958 | unsigned long (*proc)(unsigned long a, int b); |
| 35959 | cod_parse_context context = new_cod_parse_context(); |
| 35960 | int dumped = 0; |
| 35961 | |
| 35962 | cod_code gen_code; |
| 35963 | |
| 35964 | /* test for unsigned long * int */ |
| 35965 | if (verbose) printf("test for unsigned long * int"); |
| 35966 | |
| 35967 | cod_assoc_externs(context, externs); |
| 35968 | cod_parse_for_context(extern_string, context); |
| 35969 | |
| 35970 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, int p2)", |
| 35971 | context); |
| 35972 | gen_code = cod_code_gen(code, context); |
| 35973 | proc = (unsigned long (*)(unsigned long, int))(long)gen_code->func; |
| 35974 | |
| 35975 | |
| 35976 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 35977 | unsigned long source1_ul = src1ul_vals[i]; |
| 35978 | for (j=0 ; j < sizeof(src2i_vals)/sizeof(src2i_vals[0]) ; j++) { |
| 35979 | int source2_i = src2i_vals[j]; |
| 35980 | |
| 35981 | unsigned long expected_result; |
| 35982 | unsigned long result; |
| 35983 | |
| 35984 | |
| 35985 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 35986 | |
| 35987 | expected_result = (unsigned long) (source1_ul * source2_i); |
| 35988 | |
| 35989 | result = proc(source1_ul, source2_i); |
| 35990 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 35991 | if (expected_result != result) { |
| 35992 | printf("Failed unsigned long * int test, expected %lu, got %lu, for %lu * %d\n", |
| 35993 | expected_result, result, source1_ul, source2_i); |
| 35994 | if (dumped == 0) cod_dump(gen_code); |
| 35995 | failed++; |
| 35996 | dumped++; |
| 35997 | } |
| 35998 | } |
| 35999 | } |
| 36000 | if (verbose) printf(" done\n"); |
| 36001 | cod_free_parse_context(context); |
| 36002 | cod_code_free(gen_code); |
| 36003 | } |
| 36004 | if ((only_run_test == NULL((void*)0)) || |
| 36005 | (strcmp(only_run_test, "ul*u") == 0)) { |
| 36006 | int i, j; |
| 36007 | static char code[] = "{\n\ |
| 36008 | unsigned long a = p1;\n\ |
| 36009 | unsigned int b = p2;\n\ |
| 36010 | return a * b;\n\ |
| 36011 | }"; |
| 36012 | |
| 36013 | unsigned long (*proc)(unsigned long a, unsigned int b); |
| 36014 | cod_parse_context context = new_cod_parse_context(); |
| 36015 | int dumped = 0; |
| 36016 | |
| 36017 | cod_code gen_code; |
| 36018 | |
| 36019 | /* test for unsigned long * unsigned int */ |
| 36020 | if (verbose) printf("test for unsigned long * unsigned int"); |
| 36021 | |
| 36022 | cod_assoc_externs(context, externs); |
| 36023 | cod_parse_for_context(extern_string, context); |
| 36024 | |
| 36025 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, unsigned int p2)", |
| 36026 | context); |
| 36027 | gen_code = cod_code_gen(code, context); |
| 36028 | proc = (unsigned long (*)(unsigned long, unsigned int))(long)gen_code->func; |
| 36029 | |
| 36030 | |
| 36031 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 36032 | unsigned long source1_ul = src1ul_vals[i]; |
| 36033 | for (j=0 ; j < sizeof(src2u_vals)/sizeof(src2u_vals[0]) ; j++) { |
| 36034 | unsigned int source2_u = src2u_vals[j]; |
| 36035 | |
| 36036 | unsigned long expected_result; |
| 36037 | unsigned long result; |
| 36038 | |
| 36039 | |
| 36040 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 36041 | |
| 36042 | expected_result = (unsigned long) (source1_ul * source2_u); |
| 36043 | |
| 36044 | result = proc(source1_ul, source2_u); |
| 36045 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 36046 | if (expected_result != result) { |
| 36047 | printf("Failed unsigned long * unsigned int test, expected %lu, got %lu, for %lu * %u\n", |
| 36048 | expected_result, result, source1_ul, source2_u); |
| 36049 | if (dumped == 0) cod_dump(gen_code); |
| 36050 | failed++; |
| 36051 | dumped++; |
| 36052 | } |
| 36053 | } |
| 36054 | } |
| 36055 | if (verbose) printf(" done\n"); |
| 36056 | cod_free_parse_context(context); |
| 36057 | cod_code_free(gen_code); |
| 36058 | } |
| 36059 | if ((only_run_test == NULL((void*)0)) || |
| 36060 | (strcmp(only_run_test, "ul*ul") == 0)) { |
| 36061 | int i, j; |
| 36062 | static char code[] = "{\n\ |
| 36063 | unsigned long a = p1;\n\ |
| 36064 | unsigned long b = p2;\n\ |
| 36065 | return a * b;\n\ |
| 36066 | }"; |
| 36067 | |
| 36068 | unsigned long (*proc)(unsigned long a, unsigned long b); |
| 36069 | cod_parse_context context = new_cod_parse_context(); |
| 36070 | int dumped = 0; |
| 36071 | |
| 36072 | cod_code gen_code; |
| 36073 | |
| 36074 | /* test for unsigned long * unsigned long */ |
| 36075 | if (verbose) printf("test for unsigned long * unsigned long"); |
| 36076 | |
| 36077 | cod_assoc_externs(context, externs); |
| 36078 | cod_parse_for_context(extern_string, context); |
| 36079 | |
| 36080 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, unsigned long p2)", |
| 36081 | context); |
| 36082 | gen_code = cod_code_gen(code, context); |
| 36083 | proc = (unsigned long (*)(unsigned long, unsigned long))(long)gen_code->func; |
| 36084 | |
| 36085 | |
| 36086 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 36087 | unsigned long source1_ul = src1ul_vals[i]; |
| 36088 | for (j=0 ; j < sizeof(src2ul_vals)/sizeof(src2ul_vals[0]) ; j++) { |
| 36089 | unsigned long source2_ul = src2ul_vals[j]; |
| 36090 | |
| 36091 | unsigned long expected_result; |
| 36092 | unsigned long result; |
| 36093 | |
| 36094 | |
| 36095 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 36096 | |
| 36097 | expected_result = (unsigned long) (source1_ul * source2_ul); |
| 36098 | |
| 36099 | result = proc(source1_ul, source2_ul); |
| 36100 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 36101 | if (expected_result != result) { |
| 36102 | printf("Failed unsigned long * unsigned long test, expected %lu, got %lu, for %lu * %lu\n", |
| 36103 | expected_result, result, source1_ul, source2_ul); |
| 36104 | if (dumped == 0) cod_dump(gen_code); |
| 36105 | failed++; |
| 36106 | dumped++; |
| 36107 | } |
| 36108 | } |
| 36109 | } |
| 36110 | if (verbose) printf(" done\n"); |
| 36111 | cod_free_parse_context(context); |
| 36112 | cod_code_free(gen_code); |
| 36113 | } |
| 36114 | if ((only_run_test == NULL((void*)0)) || |
| 36115 | (strcmp(only_run_test, "ul*l") == 0)) { |
| 36116 | int i, j; |
| 36117 | static char code[] = "{\n\ |
| 36118 | unsigned long a = p1;\n\ |
| 36119 | long b = p2;\n\ |
| 36120 | return a * b;\n\ |
| 36121 | }"; |
| 36122 | |
| 36123 | unsigned long (*proc)(unsigned long a, long b); |
| 36124 | cod_parse_context context = new_cod_parse_context(); |
| 36125 | int dumped = 0; |
| 36126 | |
| 36127 | cod_code gen_code; |
| 36128 | |
| 36129 | /* test for unsigned long * long */ |
| 36130 | if (verbose) printf("test for unsigned long * long"); |
| 36131 | |
| 36132 | cod_assoc_externs(context, externs); |
| 36133 | cod_parse_for_context(extern_string, context); |
| 36134 | |
| 36135 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, long p2)", |
| 36136 | context); |
| 36137 | gen_code = cod_code_gen(code, context); |
| 36138 | proc = (unsigned long (*)(unsigned long, long))(long)gen_code->func; |
| 36139 | |
| 36140 | |
| 36141 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 36142 | unsigned long source1_ul = src1ul_vals[i]; |
| 36143 | for (j=0 ; j < sizeof(src2l_vals)/sizeof(src2l_vals[0]) ; j++) { |
| 36144 | long source2_l = src2l_vals[j]; |
| 36145 | |
| 36146 | unsigned long expected_result; |
| 36147 | unsigned long result; |
| 36148 | |
| 36149 | |
| 36150 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 36151 | |
| 36152 | expected_result = (unsigned long) (source1_ul * source2_l); |
| 36153 | |
| 36154 | result = proc(source1_ul, source2_l); |
| 36155 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 36156 | if (expected_result != result) { |
| 36157 | printf("Failed unsigned long * long test, expected %lu, got %lu, for %lu * %ld\n", |
| 36158 | expected_result, result, source1_ul, source2_l); |
| 36159 | if (dumped == 0) cod_dump(gen_code); |
| 36160 | failed++; |
| 36161 | dumped++; |
| 36162 | } |
| 36163 | } |
| 36164 | } |
| 36165 | if (verbose) printf(" done\n"); |
| 36166 | cod_free_parse_context(context); |
| 36167 | cod_code_free(gen_code); |
| 36168 | } |
| 36169 | if ((only_run_test == NULL((void*)0)) || |
| 36170 | (strcmp(only_run_test, "ul*f") == 0)) { |
| 36171 | int i, j; |
| 36172 | static char code[] = "{\n\ |
| 36173 | unsigned long a = p1;\n\ |
| 36174 | float b = p2;\n\ |
| 36175 | return a * b;\n\ |
| 36176 | }"; |
| 36177 | |
| 36178 | unsigned long (*proc)(unsigned long a, float b); |
| 36179 | cod_parse_context context = new_cod_parse_context(); |
| 36180 | int dumped = 0; |
| 36181 | |
| 36182 | cod_code gen_code; |
| 36183 | |
| 36184 | /* test for unsigned long * float */ |
| 36185 | if (verbose) printf("test for unsigned long * float"); |
| 36186 | |
| 36187 | cod_assoc_externs(context, externs); |
| 36188 | cod_parse_for_context(extern_string, context); |
| 36189 | |
| 36190 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, float p2)", |
| 36191 | context); |
| 36192 | gen_code = cod_code_gen(code, context); |
| 36193 | proc = (unsigned long (*)(unsigned long, float))(long)gen_code->func; |
| 36194 | |
| 36195 | |
| 36196 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 36197 | unsigned long source1_ul = src1ul_vals[i]; |
| 36198 | for (j=0 ; j < sizeof(src2f_vals)/sizeof(src2f_vals[0]) ; j++) { |
| 36199 | float source2_f = src2f_vals[j]; |
| 36200 | double range = 0.000001 * (fabs((double)source1_ul * (double)source2_f)); |
| 36201 | unsigned long expected_result; |
| 36202 | unsigned long result; |
| 36203 | |
| 36204 | |
| 36205 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 36206 | |
| 36207 | expected_result = (unsigned long) (source1_ul * source2_f); |
| 36208 | |
| 36209 | result = proc(source1_ul, source2_f); |
| 36210 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 36211 | range += 1.0; |
| 36212 | if ((result > (expected_result + range)) || (result < (expected_result - range))) { |
| 36213 | printf("Failed unsigned long * float test, expected %lu, got %lu, for %lu * %g\n", |
| 36214 | expected_result, result, source1_ul, source2_f); |
| 36215 | if (dumped == 0) cod_dump(gen_code); |
| 36216 | failed++; |
| 36217 | dumped++; |
| 36218 | } |
| 36219 | } |
| 36220 | } |
| 36221 | if (verbose) printf(" done\n"); |
| 36222 | cod_free_parse_context(context); |
| 36223 | cod_code_free(gen_code); |
| 36224 | } |
| 36225 | if ((only_run_test == NULL((void*)0)) || |
| 36226 | (strcmp(only_run_test, "ul*d") == 0)) { |
| 36227 | int i, j; |
| 36228 | static char code[] = "{\n\ |
| 36229 | unsigned long a = p1;\n\ |
| 36230 | double b = p2;\n\ |
| 36231 | return a * b;\n\ |
| 36232 | }"; |
| 36233 | |
| 36234 | unsigned long (*proc)(unsigned long a, double b); |
| 36235 | cod_parse_context context = new_cod_parse_context(); |
| 36236 | int dumped = 0; |
| 36237 | |
| 36238 | cod_code gen_code; |
| 36239 | |
| 36240 | /* test for unsigned long * double */ |
| 36241 | if (verbose) printf("test for unsigned long * double"); |
| 36242 | |
| 36243 | cod_assoc_externs(context, externs); |
| 36244 | cod_parse_for_context(extern_string, context); |
| 36245 | |
| 36246 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, double p2)", |
| 36247 | context); |
| 36248 | gen_code = cod_code_gen(code, context); |
| 36249 | proc = (unsigned long (*)(unsigned long, double))(long)gen_code->func; |
| 36250 | |
| 36251 | |
| 36252 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 36253 | unsigned long source1_ul = src1ul_vals[i]; |
| 36254 | for (j=0 ; j < sizeof(src2d_vals)/sizeof(src2d_vals[0]) ; j++) { |
| 36255 | double source2_d = src2d_vals[j]; |
| 36256 | |
| 36257 | unsigned long expected_result; |
| 36258 | unsigned long result; |
| 36259 | |
| 36260 | |
| 36261 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 36262 | |
| 36263 | expected_result = (unsigned long) (source1_ul * source2_d); |
| 36264 | |
| 36265 | result = proc(source1_ul, source2_d); |
| 36266 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 36267 | if (expected_result != result) { |
| 36268 | printf("Failed unsigned long * double test, expected %lu, got %lu, for %lu * %g\n", |
| 36269 | expected_result, result, source1_ul, source2_d); |
| 36270 | if (dumped == 0) cod_dump(gen_code); |
| 36271 | failed++; |
| 36272 | dumped++; |
| 36273 | } |
| 36274 | } |
| 36275 | } |
| 36276 | if (verbose) printf(" done\n"); |
| 36277 | cod_free_parse_context(context); |
| 36278 | cod_code_free(gen_code); |
| 36279 | } |
| 36280 | } |
| 36281 | void mult_l_tests() |
| 36282 | { |
| 36283 | if ((only_run_test == NULL((void*)0)) || |
| 36284 | (strcmp(only_run_test, "l*c") == 0)) { |
| 36285 | int i, j; |
| 36286 | static char code[] = "{\n\ |
| 36287 | long a = p1;\n\ |
| 36288 | signed char b = p2;\n\ |
| 36289 | return a * b;\n\ |
| 36290 | }"; |
| 36291 | |
| 36292 | long (*proc)(long a, signed char b); |
| 36293 | cod_parse_context context = new_cod_parse_context(); |
| 36294 | int dumped = 0; |
| 36295 | |
| 36296 | cod_code gen_code; |
| 36297 | |
| 36298 | /* test for long * signed char */ |
| 36299 | if (verbose) printf("test for long * signed char"); |
| 36300 | |
| 36301 | cod_assoc_externs(context, externs); |
| 36302 | cod_parse_for_context(extern_string, context); |
| 36303 | |
| 36304 | cod_subroutine_declaration("long proc(long p1, signed char p2)", |
| 36305 | context); |
| 36306 | gen_code = cod_code_gen(code, context); |
| 36307 | proc = (long (*)(long, signed char))(long)gen_code->func; |
| 36308 | |
| 36309 | |
| 36310 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 36311 | long source1_l = src1l_vals[i]; |
| 36312 | for (j=0 ; j < sizeof(src2c_vals)/sizeof(src2c_vals[0]) ; j++) { |
| 36313 | signed char source2_c = src2c_vals[j]; |
| 36314 | |
| 36315 | long expected_result; |
| 36316 | long result; |
| 36317 | |
| 36318 | |
| 36319 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 36320 | |
| 36321 | expected_result = (long) (source1_l * source2_c); |
| 36322 | |
| 36323 | result = proc(source1_l, source2_c); |
| 36324 | if (expected_result != result) { |
| 36325 | printf("Failed long * signed char test, expected %ld, got %ld, for %ld * %d\n", |
| 36326 | expected_result, result, source1_l, source2_c); |
| 36327 | if (dumped == 0) cod_dump(gen_code); |
| 36328 | failed++; |
| 36329 | dumped++; |
| 36330 | } |
| 36331 | } |
| 36332 | } |
| 36333 | if (verbose) printf(" done\n"); |
| 36334 | cod_free_parse_context(context); |
| 36335 | cod_code_free(gen_code); |
| 36336 | } |
| 36337 | if ((only_run_test == NULL((void*)0)) || |
| 36338 | (strcmp(only_run_test, "l*uc") == 0)) { |
| 36339 | int i, j; |
| 36340 | static char code[] = "{\n\ |
| 36341 | long a = p1;\n\ |
| 36342 | unsigned char b = p2;\n\ |
| 36343 | return a * b;\n\ |
| 36344 | }"; |
| 36345 | |
| 36346 | long (*proc)(long a, unsigned char b); |
| 36347 | cod_parse_context context = new_cod_parse_context(); |
| 36348 | int dumped = 0; |
| 36349 | |
| 36350 | cod_code gen_code; |
| 36351 | |
| 36352 | /* test for long * unsigned char */ |
| 36353 | if (verbose) printf("test for long * unsigned char"); |
| 36354 | |
| 36355 | cod_assoc_externs(context, externs); |
| 36356 | cod_parse_for_context(extern_string, context); |
| 36357 | |
| 36358 | cod_subroutine_declaration("long proc(long p1, unsigned char p2)", |
| 36359 | context); |
| 36360 | gen_code = cod_code_gen(code, context); |
| 36361 | proc = (long (*)(long, unsigned char))(long)gen_code->func; |
| 36362 | |
| 36363 | |
| 36364 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 36365 | long source1_l = src1l_vals[i]; |
| 36366 | for (j=0 ; j < sizeof(src2uc_vals)/sizeof(src2uc_vals[0]) ; j++) { |
| 36367 | unsigned char source2_uc = src2uc_vals[j]; |
| 36368 | |
| 36369 | long expected_result; |
| 36370 | long result; |
| 36371 | |
| 36372 | |
| 36373 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 36374 | |
| 36375 | expected_result = (long) (source1_l * source2_uc); |
| 36376 | |
| 36377 | result = proc(source1_l, source2_uc); |
| 36378 | if (expected_result != result) { |
| 36379 | printf("Failed long * unsigned char test, expected %ld, got %ld, for %ld * %u\n", |
| 36380 | expected_result, result, source1_l, source2_uc); |
| 36381 | if (dumped == 0) cod_dump(gen_code); |
| 36382 | failed++; |
| 36383 | dumped++; |
| 36384 | } |
| 36385 | } |
| 36386 | } |
| 36387 | if (verbose) printf(" done\n"); |
| 36388 | cod_free_parse_context(context); |
| 36389 | cod_code_free(gen_code); |
| 36390 | } |
| 36391 | if ((only_run_test == NULL((void*)0)) || |
| 36392 | (strcmp(only_run_test, "l*s") == 0)) { |
| 36393 | int i, j; |
| 36394 | static char code[] = "{\n\ |
| 36395 | long a = p1;\n\ |
| 36396 | short b = p2;\n\ |
| 36397 | return a * b;\n\ |
| 36398 | }"; |
| 36399 | |
| 36400 | long (*proc)(long a, short b); |
| 36401 | cod_parse_context context = new_cod_parse_context(); |
| 36402 | int dumped = 0; |
| 36403 | |
| 36404 | cod_code gen_code; |
| 36405 | |
| 36406 | /* test for long * short */ |
| 36407 | if (verbose) printf("test for long * short"); |
| 36408 | |
| 36409 | cod_assoc_externs(context, externs); |
| 36410 | cod_parse_for_context(extern_string, context); |
| 36411 | |
| 36412 | cod_subroutine_declaration("long proc(long p1, short p2)", |
| 36413 | context); |
| 36414 | gen_code = cod_code_gen(code, context); |
| 36415 | proc = (long (*)(long, short))(long)gen_code->func; |
| 36416 | |
| 36417 | |
| 36418 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 36419 | long source1_l = src1l_vals[i]; |
| 36420 | for (j=0 ; j < sizeof(src2s_vals)/sizeof(src2s_vals[0]) ; j++) { |
| 36421 | short source2_s = src2s_vals[j]; |
| 36422 | |
| 36423 | long expected_result; |
| 36424 | long result; |
| 36425 | |
| 36426 | |
| 36427 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 36428 | |
| 36429 | expected_result = (long) (source1_l * source2_s); |
| 36430 | |
| 36431 | result = proc(source1_l, source2_s); |
| 36432 | if (expected_result != result) { |
| 36433 | printf("Failed long * short test, expected %ld, got %ld, for %ld * %d\n", |
| 36434 | expected_result, result, source1_l, source2_s); |
| 36435 | if (dumped == 0) cod_dump(gen_code); |
| 36436 | failed++; |
| 36437 | dumped++; |
| 36438 | } |
| 36439 | } |
| 36440 | } |
| 36441 | if (verbose) printf(" done\n"); |
| 36442 | cod_free_parse_context(context); |
| 36443 | cod_code_free(gen_code); |
| 36444 | } |
| 36445 | if ((only_run_test == NULL((void*)0)) || |
| 36446 | (strcmp(only_run_test, "l*us") == 0)) { |
| 36447 | int i, j; |
| 36448 | static char code[] = "{\n\ |
| 36449 | long a = p1;\n\ |
| 36450 | unsigned short b = p2;\n\ |
| 36451 | return a * b;\n\ |
| 36452 | }"; |
| 36453 | |
| 36454 | long (*proc)(long a, unsigned short b); |
| 36455 | cod_parse_context context = new_cod_parse_context(); |
| 36456 | int dumped = 0; |
| 36457 | |
| 36458 | cod_code gen_code; |
| 36459 | |
| 36460 | /* test for long * unsigned short */ |
| 36461 | if (verbose) printf("test for long * unsigned short"); |
| 36462 | |
| 36463 | cod_assoc_externs(context, externs); |
| 36464 | cod_parse_for_context(extern_string, context); |
| 36465 | |
| 36466 | cod_subroutine_declaration("long proc(long p1, unsigned short p2)", |
| 36467 | context); |
| 36468 | gen_code = cod_code_gen(code, context); |
| 36469 | proc = (long (*)(long, unsigned short))(long)gen_code->func; |
| 36470 | |
| 36471 | |
| 36472 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 36473 | long source1_l = src1l_vals[i]; |
| 36474 | for (j=0 ; j < sizeof(src2us_vals)/sizeof(src2us_vals[0]) ; j++) { |
| 36475 | unsigned short source2_us = src2us_vals[j]; |
| 36476 | |
| 36477 | long expected_result; |
| 36478 | long result; |
| 36479 | |
| 36480 | |
| 36481 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 36482 | |
| 36483 | expected_result = (long) (source1_l * source2_us); |
| 36484 | |
| 36485 | result = proc(source1_l, source2_us); |
| 36486 | if (expected_result != result) { |
| 36487 | printf("Failed long * unsigned short test, expected %ld, got %ld, for %ld * %u\n", |
| 36488 | expected_result, result, source1_l, source2_us); |
| 36489 | if (dumped == 0) cod_dump(gen_code); |
| 36490 | failed++; |
| 36491 | dumped++; |
| 36492 | } |
| 36493 | } |
| 36494 | } |
| 36495 | if (verbose) printf(" done\n"); |
| 36496 | cod_free_parse_context(context); |
| 36497 | cod_code_free(gen_code); |
| 36498 | } |
| 36499 | if ((only_run_test == NULL((void*)0)) || |
| 36500 | (strcmp(only_run_test, "l*i") == 0)) { |
| 36501 | int i, j; |
| 36502 | static char code[] = "{\n\ |
| 36503 | long a = p1;\n\ |
| 36504 | int b = p2;\n\ |
| 36505 | return a * b;\n\ |
| 36506 | }"; |
| 36507 | |
| 36508 | long (*proc)(long a, int b); |
| 36509 | cod_parse_context context = new_cod_parse_context(); |
| 36510 | int dumped = 0; |
| 36511 | |
| 36512 | cod_code gen_code; |
| 36513 | |
| 36514 | /* test for long * int */ |
| 36515 | if (verbose) printf("test for long * int"); |
| 36516 | |
| 36517 | cod_assoc_externs(context, externs); |
| 36518 | cod_parse_for_context(extern_string, context); |
| 36519 | |
| 36520 | cod_subroutine_declaration("long proc(long p1, int p2)", |
| 36521 | context); |
| 36522 | gen_code = cod_code_gen(code, context); |
| 36523 | proc = (long (*)(long, int))(long)gen_code->func; |
| 36524 | |
| 36525 | |
| 36526 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 36527 | long source1_l = src1l_vals[i]; |
| 36528 | for (j=0 ; j < sizeof(src2i_vals)/sizeof(src2i_vals[0]) ; j++) { |
| 36529 | int source2_i = src2i_vals[j]; |
| 36530 | |
| 36531 | long expected_result; |
| 36532 | long result; |
| 36533 | |
| 36534 | |
| 36535 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 36536 | |
| 36537 | expected_result = (long) (source1_l * source2_i); |
| 36538 | |
| 36539 | result = proc(source1_l, source2_i); |
| 36540 | if (expected_result != result) { |
| 36541 | printf("Failed long * int test, expected %ld, got %ld, for %ld * %d\n", |
| 36542 | expected_result, result, source1_l, source2_i); |
| 36543 | if (dumped == 0) cod_dump(gen_code); |
| 36544 | failed++; |
| 36545 | dumped++; |
| 36546 | } |
| 36547 | } |
| 36548 | } |
| 36549 | if (verbose) printf(" done\n"); |
| 36550 | cod_free_parse_context(context); |
| 36551 | cod_code_free(gen_code); |
| 36552 | } |
| 36553 | if ((only_run_test == NULL((void*)0)) || |
| 36554 | (strcmp(only_run_test, "l*u") == 0)) { |
| 36555 | int i, j; |
| 36556 | static char code[] = "{\n\ |
| 36557 | long a = p1;\n\ |
| 36558 | unsigned int b = p2;\n\ |
| 36559 | return a * b;\n\ |
| 36560 | }"; |
| 36561 | |
| 36562 | long (*proc)(long a, unsigned int b); |
| 36563 | cod_parse_context context = new_cod_parse_context(); |
| 36564 | int dumped = 0; |
| 36565 | |
| 36566 | cod_code gen_code; |
| 36567 | |
| 36568 | /* test for long * unsigned int */ |
| 36569 | if (verbose) printf("test for long * unsigned int"); |
| 36570 | |
| 36571 | cod_assoc_externs(context, externs); |
| 36572 | cod_parse_for_context(extern_string, context); |
| 36573 | |
| 36574 | cod_subroutine_declaration("long proc(long p1, unsigned int p2)", |
| 36575 | context); |
| 36576 | gen_code = cod_code_gen(code, context); |
| 36577 | proc = (long (*)(long, unsigned int))(long)gen_code->func; |
| 36578 | |
| 36579 | |
| 36580 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 36581 | long source1_l = src1l_vals[i]; |
| 36582 | for (j=0 ; j < sizeof(src2u_vals)/sizeof(src2u_vals[0]) ; j++) { |
| 36583 | unsigned int source2_u = src2u_vals[j]; |
| 36584 | |
| 36585 | long expected_result; |
| 36586 | long result; |
| 36587 | |
| 36588 | |
| 36589 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 36590 | |
| 36591 | expected_result = (long) (source1_l * source2_u); |
| 36592 | |
| 36593 | result = proc(source1_l, source2_u); |
| 36594 | if (expected_result != result) { |
| 36595 | printf("Failed long * unsigned int test, expected %ld, got %ld, for %ld * %u\n", |
| 36596 | expected_result, result, source1_l, source2_u); |
| 36597 | if (dumped == 0) cod_dump(gen_code); |
| 36598 | failed++; |
| 36599 | dumped++; |
| 36600 | } |
| 36601 | } |
| 36602 | } |
| 36603 | if (verbose) printf(" done\n"); |
| 36604 | cod_free_parse_context(context); |
| 36605 | cod_code_free(gen_code); |
| 36606 | } |
| 36607 | if ((only_run_test == NULL((void*)0)) || |
| 36608 | (strcmp(only_run_test, "l*ul") == 0)) { |
| 36609 | int i, j; |
| 36610 | static char code[] = "{\n\ |
| 36611 | long a = p1;\n\ |
| 36612 | unsigned long b = p2;\n\ |
| 36613 | return a * b;\n\ |
| 36614 | }"; |
| 36615 | |
| 36616 | long (*proc)(long a, unsigned long b); |
| 36617 | cod_parse_context context = new_cod_parse_context(); |
| 36618 | int dumped = 0; |
| 36619 | |
| 36620 | cod_code gen_code; |
| 36621 | |
| 36622 | /* test for long * unsigned long */ |
| 36623 | if (verbose) printf("test for long * unsigned long"); |
| 36624 | |
| 36625 | cod_assoc_externs(context, externs); |
| 36626 | cod_parse_for_context(extern_string, context); |
| 36627 | |
| 36628 | cod_subroutine_declaration("long proc(long p1, unsigned long p2)", |
| 36629 | context); |
| 36630 | gen_code = cod_code_gen(code, context); |
| 36631 | proc = (long (*)(long, unsigned long))(long)gen_code->func; |
| 36632 | |
| 36633 | |
| 36634 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 36635 | long source1_l = src1l_vals[i]; |
| 36636 | for (j=0 ; j < sizeof(src2ul_vals)/sizeof(src2ul_vals[0]) ; j++) { |
| 36637 | unsigned long source2_ul = src2ul_vals[j]; |
| 36638 | |
| 36639 | long expected_result; |
| 36640 | long result; |
| 36641 | |
| 36642 | |
| 36643 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 36644 | |
| 36645 | expected_result = (long) (source1_l * source2_ul); |
| 36646 | |
| 36647 | result = proc(source1_l, source2_ul); |
| 36648 | if (expected_result != result) { |
| 36649 | printf("Failed long * unsigned long test, expected %ld, got %ld, for %ld * %lu\n", |
| 36650 | expected_result, result, source1_l, source2_ul); |
| 36651 | if (dumped == 0) cod_dump(gen_code); |
| 36652 | failed++; |
| 36653 | dumped++; |
| 36654 | } |
| 36655 | } |
| 36656 | } |
| 36657 | if (verbose) printf(" done\n"); |
| 36658 | cod_free_parse_context(context); |
| 36659 | cod_code_free(gen_code); |
| 36660 | } |
| 36661 | if ((only_run_test == NULL((void*)0)) || |
| 36662 | (strcmp(only_run_test, "l*l") == 0)) { |
| 36663 | int i, j; |
| 36664 | static char code[] = "{\n\ |
| 36665 | long a = p1;\n\ |
| 36666 | long b = p2;\n\ |
| 36667 | return a * b;\n\ |
| 36668 | }"; |
| 36669 | |
| 36670 | long (*proc)(long a, long b); |
| 36671 | cod_parse_context context = new_cod_parse_context(); |
| 36672 | int dumped = 0; |
| 36673 | |
| 36674 | cod_code gen_code; |
| 36675 | |
| 36676 | /* test for long * long */ |
| 36677 | if (verbose) printf("test for long * long"); |
| 36678 | |
| 36679 | cod_assoc_externs(context, externs); |
| 36680 | cod_parse_for_context(extern_string, context); |
| 36681 | |
| 36682 | cod_subroutine_declaration("long proc(long p1, long p2)", |
| 36683 | context); |
| 36684 | gen_code = cod_code_gen(code, context); |
| 36685 | proc = (long (*)(long, long))(long)gen_code->func; |
| 36686 | |
| 36687 | |
| 36688 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 36689 | long source1_l = src1l_vals[i]; |
| 36690 | for (j=0 ; j < sizeof(src2l_vals)/sizeof(src2l_vals[0]) ; j++) { |
| 36691 | long source2_l = src2l_vals[j]; |
| 36692 | |
| 36693 | long expected_result; |
| 36694 | long result; |
| 36695 | |
| 36696 | |
| 36697 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 36698 | |
| 36699 | expected_result = (long) (source1_l * source2_l); |
| 36700 | |
| 36701 | result = proc(source1_l, source2_l); |
| 36702 | if (expected_result != result) { |
| 36703 | printf("Failed long * long test, expected %ld, got %ld, for %ld * %ld\n", |
| 36704 | expected_result, result, source1_l, source2_l); |
| 36705 | if (dumped == 0) cod_dump(gen_code); |
| 36706 | failed++; |
| 36707 | dumped++; |
| 36708 | } |
| 36709 | } |
| 36710 | } |
| 36711 | if (verbose) printf(" done\n"); |
| 36712 | cod_free_parse_context(context); |
| 36713 | cod_code_free(gen_code); |
| 36714 | } |
| 36715 | if ((only_run_test == NULL((void*)0)) || |
| 36716 | (strcmp(only_run_test, "l*f") == 0)) { |
| 36717 | int i, j; |
| 36718 | static char code[] = "{\n\ |
| 36719 | long a = p1;\n\ |
| 36720 | float b = p2;\n\ |
| 36721 | return a * b;\n\ |
| 36722 | }"; |
| 36723 | |
| 36724 | long (*proc)(long a, float b); |
| 36725 | cod_parse_context context = new_cod_parse_context(); |
| 36726 | int dumped = 0; |
| 36727 | |
| 36728 | cod_code gen_code; |
| 36729 | |
| 36730 | /* test for long * float */ |
| 36731 | if (verbose) printf("test for long * float"); |
| 36732 | |
| 36733 | cod_assoc_externs(context, externs); |
| 36734 | cod_parse_for_context(extern_string, context); |
| 36735 | |
| 36736 | cod_subroutine_declaration("long proc(long p1, float p2)", |
| 36737 | context); |
| 36738 | gen_code = cod_code_gen(code, context); |
| 36739 | proc = (long (*)(long, float))(long)gen_code->func; |
| 36740 | |
| 36741 | |
| 36742 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 36743 | long source1_l = src1l_vals[i]; |
| 36744 | for (j=0 ; j < sizeof(src2f_vals)/sizeof(src2f_vals[0]) ; j++) { |
| 36745 | float source2_f = src2f_vals[j]; |
| 36746 | double range = 0.000001 * (fabs((double)source1_l * (double)source2_f)); |
| 36747 | long expected_result; |
| 36748 | long result; |
| 36749 | |
| 36750 | |
| 36751 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 36752 | |
| 36753 | expected_result = (long) (source1_l * source2_f); |
| 36754 | |
| 36755 | result = proc(source1_l, source2_f); |
| 36756 | range += 1.0; |
| 36757 | if ((result > (expected_result + range)) || (result < (expected_result - range))) { |
| 36758 | printf("Failed long * float test, expected %ld, got %ld, for %ld * %g\n", |
| 36759 | expected_result, result, source1_l, source2_f); |
| 36760 | if (dumped == 0) cod_dump(gen_code); |
| 36761 | failed++; |
| 36762 | dumped++; |
| 36763 | } |
| 36764 | } |
| 36765 | } |
| 36766 | if (verbose) printf(" done\n"); |
| 36767 | cod_free_parse_context(context); |
| 36768 | cod_code_free(gen_code); |
| 36769 | } |
| 36770 | if ((only_run_test == NULL((void*)0)) || |
| 36771 | (strcmp(only_run_test, "l*d") == 0)) { |
| 36772 | int i, j; |
| 36773 | static char code[] = "{\n\ |
| 36774 | long a = p1;\n\ |
| 36775 | double b = p2;\n\ |
| 36776 | return a * b;\n\ |
| 36777 | }"; |
| 36778 | |
| 36779 | long (*proc)(long a, double b); |
| 36780 | cod_parse_context context = new_cod_parse_context(); |
| 36781 | int dumped = 0; |
| 36782 | |
| 36783 | cod_code gen_code; |
| 36784 | |
| 36785 | /* test for long * double */ |
| 36786 | if (verbose) printf("test for long * double"); |
| 36787 | |
| 36788 | cod_assoc_externs(context, externs); |
| 36789 | cod_parse_for_context(extern_string, context); |
| 36790 | |
| 36791 | cod_subroutine_declaration("long proc(long p1, double p2)", |
| 36792 | context); |
| 36793 | gen_code = cod_code_gen(code, context); |
| 36794 | proc = (long (*)(long, double))(long)gen_code->func; |
| 36795 | |
| 36796 | |
| 36797 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 36798 | long source1_l = src1l_vals[i]; |
| 36799 | for (j=0 ; j < sizeof(src2d_vals)/sizeof(src2d_vals[0]) ; j++) { |
| 36800 | double source2_d = src2d_vals[j]; |
| 36801 | |
| 36802 | long expected_result; |
| 36803 | long result; |
| 36804 | |
| 36805 | |
| 36806 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 36807 | |
| 36808 | expected_result = (long) (source1_l * source2_d); |
| 36809 | |
| 36810 | result = proc(source1_l, source2_d); |
| 36811 | if (expected_result != result) { |
| 36812 | printf("Failed long * double test, expected %ld, got %ld, for %ld * %g\n", |
| 36813 | expected_result, result, source1_l, source2_d); |
| 36814 | if (dumped == 0) cod_dump(gen_code); |
| 36815 | failed++; |
| 36816 | dumped++; |
| 36817 | } |
| 36818 | } |
| 36819 | } |
| 36820 | if (verbose) printf(" done\n"); |
| 36821 | cod_free_parse_context(context); |
| 36822 | cod_code_free(gen_code); |
| 36823 | } |
| 36824 | } |
| 36825 | void mult_f_tests() |
| 36826 | { |
| 36827 | if ((only_run_test == NULL((void*)0)) || |
| 36828 | (strcmp(only_run_test, "f*c") == 0)) { |
| 36829 | int i, j; |
| 36830 | static char code[] = "{\n\ |
| 36831 | float a = p1;\n\ |
| 36832 | signed char b = p2;\n\ |
| 36833 | return a * b;\n\ |
| 36834 | }"; |
| 36835 | |
| 36836 | float (*proc)(float a, signed char b); |
| 36837 | cod_parse_context context = new_cod_parse_context(); |
| 36838 | int dumped = 0; |
| 36839 | |
| 36840 | cod_code gen_code; |
| 36841 | |
| 36842 | /* test for float * signed char */ |
| 36843 | if (verbose) printf("test for float * signed char"); |
| 36844 | |
| 36845 | cod_assoc_externs(context, externs); |
| 36846 | cod_parse_for_context(extern_string, context); |
| 36847 | |
| 36848 | cod_subroutine_declaration("float proc(float p1, signed char p2)", |
| 36849 | context); |
| 36850 | gen_code = cod_code_gen(code, context); |
| 36851 | proc = (float (*)(float, signed char))(long)gen_code->func; |
| 36852 | |
| 36853 | |
| 36854 | for (i=0 ; i < sizeof(src1f_vals)/sizeof(src1f_vals[0]) ; i++) { |
| 36855 | float source1_f = src1f_vals[i]; |
| 36856 | for (j=0 ; j < sizeof(src2c_vals)/sizeof(src2c_vals[0]) ; j++) { |
| 36857 | signed char source2_c = src2c_vals[j]; |
| 36858 | double range = 0.000001 * (fabs((double)source1_f * (double)source2_c)); |
| 36859 | float expected_result; |
| 36860 | float result; |
| 36861 | |
| 36862 | |
| 36863 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 36864 | |
| 36865 | expected_result = (float) (source1_f * source2_c); |
| 36866 | |
| 36867 | result = proc(source1_f, source2_c); |
| 36868 | range += 1.0; |
| 36869 | if ((result > (expected_result + range)) || (result < (expected_result - range))) { |
| 36870 | printf("Failed float * signed char test, expected %g, got %g, for %g * %d\n", |
| 36871 | expected_result, result, source1_f, source2_c); |
| 36872 | if (dumped == 0) cod_dump(gen_code); |
| 36873 | failed++; |
| 36874 | dumped++; |
| 36875 | } |
| 36876 | } |
| 36877 | } |
| 36878 | if (verbose) printf(" done\n"); |
| 36879 | cod_free_parse_context(context); |
| 36880 | cod_code_free(gen_code); |
| 36881 | } |
| 36882 | if ((only_run_test == NULL((void*)0)) || |
| 36883 | (strcmp(only_run_test, "f*uc") == 0)) { |
| 36884 | int i, j; |
| 36885 | static char code[] = "{\n\ |
| 36886 | float a = p1;\n\ |
| 36887 | unsigned char b = p2;\n\ |
| 36888 | return a * b;\n\ |
| 36889 | }"; |
| 36890 | |
| 36891 | float (*proc)(float a, unsigned char b); |
| 36892 | cod_parse_context context = new_cod_parse_context(); |
| 36893 | int dumped = 0; |
| 36894 | |
| 36895 | cod_code gen_code; |
| 36896 | |
| 36897 | /* test for float * unsigned char */ |
| 36898 | if (verbose) printf("test for float * unsigned char"); |
| 36899 | |
| 36900 | cod_assoc_externs(context, externs); |
| 36901 | cod_parse_for_context(extern_string, context); |
| 36902 | |
| 36903 | cod_subroutine_declaration("float proc(float p1, unsigned char p2)", |
| 36904 | context); |
| 36905 | gen_code = cod_code_gen(code, context); |
| 36906 | proc = (float (*)(float, unsigned char))(long)gen_code->func; |
| 36907 | |
| 36908 | |
| 36909 | for (i=0 ; i < sizeof(src1f_vals)/sizeof(src1f_vals[0]) ; i++) { |
| 36910 | float source1_f = src1f_vals[i]; |
| 36911 | for (j=0 ; j < sizeof(src2uc_vals)/sizeof(src2uc_vals[0]) ; j++) { |
| 36912 | unsigned char source2_uc = src2uc_vals[j]; |
| 36913 | double range = 0.000001 * (fabs((double)source1_f * (double)source2_uc)); |
| 36914 | float expected_result; |
| 36915 | float result; |
| 36916 | |
| 36917 | |
| 36918 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 36919 | |
| 36920 | expected_result = (float) (source1_f * source2_uc); |
| 36921 | |
| 36922 | result = proc(source1_f, source2_uc); |
| 36923 | range += 1.0; |
| 36924 | if ((result > (expected_result + range)) || (result < (expected_result - range))) { |
| 36925 | printf("Failed float * unsigned char test, expected %g, got %g, for %g * %u\n", |
| 36926 | expected_result, result, source1_f, source2_uc); |
| 36927 | if (dumped == 0) cod_dump(gen_code); |
| 36928 | failed++; |
| 36929 | dumped++; |
| 36930 | } |
| 36931 | } |
| 36932 | } |
| 36933 | if (verbose) printf(" done\n"); |
| 36934 | cod_free_parse_context(context); |
| 36935 | cod_code_free(gen_code); |
| 36936 | } |
| 36937 | if ((only_run_test == NULL((void*)0)) || |
| 36938 | (strcmp(only_run_test, "f*s") == 0)) { |
| 36939 | int i, j; |
| 36940 | static char code[] = "{\n\ |
| 36941 | float a = p1;\n\ |
| 36942 | short b = p2;\n\ |
| 36943 | return a * b;\n\ |
| 36944 | }"; |
| 36945 | |
| 36946 | float (*proc)(float a, short b); |
| 36947 | cod_parse_context context = new_cod_parse_context(); |
| 36948 | int dumped = 0; |
| 36949 | |
| 36950 | cod_code gen_code; |
| 36951 | |
| 36952 | /* test for float * short */ |
| 36953 | if (verbose) printf("test for float * short"); |
| 36954 | |
| 36955 | cod_assoc_externs(context, externs); |
| 36956 | cod_parse_for_context(extern_string, context); |
| 36957 | |
| 36958 | cod_subroutine_declaration("float proc(float p1, short p2)", |
| 36959 | context); |
| 36960 | gen_code = cod_code_gen(code, context); |
| 36961 | proc = (float (*)(float, short))(long)gen_code->func; |
| 36962 | |
| 36963 | |
| 36964 | for (i=0 ; i < sizeof(src1f_vals)/sizeof(src1f_vals[0]) ; i++) { |
| 36965 | float source1_f = src1f_vals[i]; |
| 36966 | for (j=0 ; j < sizeof(src2s_vals)/sizeof(src2s_vals[0]) ; j++) { |
| 36967 | short source2_s = src2s_vals[j]; |
| 36968 | double range = 0.000001 * (fabs((double)source1_f * (double)source2_s)); |
| 36969 | float expected_result; |
| 36970 | float result; |
| 36971 | |
| 36972 | |
| 36973 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 36974 | |
| 36975 | expected_result = (float) (source1_f * source2_s); |
| 36976 | |
| 36977 | result = proc(source1_f, source2_s); |
| 36978 | range += 1.0; |
| 36979 | if ((result > (expected_result + range)) || (result < (expected_result - range))) { |
| 36980 | printf("Failed float * short test, expected %g, got %g, for %g * %d\n", |
| 36981 | expected_result, result, source1_f, source2_s); |
| 36982 | if (dumped == 0) cod_dump(gen_code); |
| 36983 | failed++; |
| 36984 | dumped++; |
| 36985 | } |
| 36986 | } |
| 36987 | } |
| 36988 | if (verbose) printf(" done\n"); |
| 36989 | cod_free_parse_context(context); |
| 36990 | cod_code_free(gen_code); |
| 36991 | } |
| 36992 | if ((only_run_test == NULL((void*)0)) || |
| 36993 | (strcmp(only_run_test, "f*us") == 0)) { |
| 36994 | int i, j; |
| 36995 | static char code[] = "{\n\ |
| 36996 | float a = p1;\n\ |
| 36997 | unsigned short b = p2;\n\ |
| 36998 | return a * b;\n\ |
| 36999 | }"; |
| 37000 | |
| 37001 | float (*proc)(float a, unsigned short b); |
| 37002 | cod_parse_context context = new_cod_parse_context(); |
| 37003 | int dumped = 0; |
| 37004 | |
| 37005 | cod_code gen_code; |
| 37006 | |
| 37007 | /* test for float * unsigned short */ |
| 37008 | if (verbose) printf("test for float * unsigned short"); |
| 37009 | |
| 37010 | cod_assoc_externs(context, externs); |
| 37011 | cod_parse_for_context(extern_string, context); |
| 37012 | |
| 37013 | cod_subroutine_declaration("float proc(float p1, unsigned short p2)", |
| 37014 | context); |
| 37015 | gen_code = cod_code_gen(code, context); |
| 37016 | proc = (float (*)(float, unsigned short))(long)gen_code->func; |
| 37017 | |
| 37018 | |
| 37019 | for (i=0 ; i < sizeof(src1f_vals)/sizeof(src1f_vals[0]) ; i++) { |
| 37020 | float source1_f = src1f_vals[i]; |
| 37021 | for (j=0 ; j < sizeof(src2us_vals)/sizeof(src2us_vals[0]) ; j++) { |
| 37022 | unsigned short source2_us = src2us_vals[j]; |
| 37023 | double range = 0.000001 * (fabs((double)source1_f * (double)source2_us)); |
| 37024 | float expected_result; |
| 37025 | float result; |
| 37026 | |
| 37027 | |
| 37028 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 37029 | |
| 37030 | expected_result = (float) (source1_f * source2_us); |
| 37031 | |
| 37032 | result = proc(source1_f, source2_us); |
| 37033 | range += 1.0; |
| 37034 | if ((result > (expected_result + range)) || (result < (expected_result - range))) { |
| 37035 | printf("Failed float * unsigned short test, expected %g, got %g, for %g * %u\n", |
| 37036 | expected_result, result, source1_f, source2_us); |
| 37037 | if (dumped == 0) cod_dump(gen_code); |
| 37038 | failed++; |
| 37039 | dumped++; |
| 37040 | } |
| 37041 | } |
| 37042 | } |
| 37043 | if (verbose) printf(" done\n"); |
| 37044 | cod_free_parse_context(context); |
| 37045 | cod_code_free(gen_code); |
| 37046 | } |
| 37047 | if ((only_run_test == NULL((void*)0)) || |
| 37048 | (strcmp(only_run_test, "f*i") == 0)) { |
| 37049 | int i, j; |
| 37050 | static char code[] = "{\n\ |
| 37051 | float a = p1;\n\ |
| 37052 | int b = p2;\n\ |
| 37053 | return a * b;\n\ |
| 37054 | }"; |
| 37055 | |
| 37056 | float (*proc)(float a, int b); |
| 37057 | cod_parse_context context = new_cod_parse_context(); |
| 37058 | int dumped = 0; |
| 37059 | |
| 37060 | cod_code gen_code; |
| 37061 | |
| 37062 | /* test for float * int */ |
| 37063 | if (verbose) printf("test for float * int"); |
| 37064 | |
| 37065 | cod_assoc_externs(context, externs); |
| 37066 | cod_parse_for_context(extern_string, context); |
| 37067 | |
| 37068 | cod_subroutine_declaration("float proc(float p1, int p2)", |
| 37069 | context); |
| 37070 | gen_code = cod_code_gen(code, context); |
| 37071 | proc = (float (*)(float, int))(long)gen_code->func; |
| 37072 | |
| 37073 | |
| 37074 | for (i=0 ; i < sizeof(src1f_vals)/sizeof(src1f_vals[0]) ; i++) { |
| 37075 | float source1_f = src1f_vals[i]; |
| 37076 | for (j=0 ; j < sizeof(src2i_vals)/sizeof(src2i_vals[0]) ; j++) { |
| 37077 | int source2_i = src2i_vals[j]; |
| 37078 | double range = 0.000001 * (fabs((double)source1_f * (double)source2_i)); |
| 37079 | float expected_result; |
| 37080 | float result; |
| 37081 | |
| 37082 | |
| 37083 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 37084 | |
| 37085 | expected_result = (float) (source1_f * source2_i); |
| 37086 | |
| 37087 | result = proc(source1_f, source2_i); |
| 37088 | range += 1.0; |
| 37089 | if ((result > (expected_result + range)) || (result < (expected_result - range))) { |
| 37090 | printf("Failed float * int test, expected %g, got %g, for %g * %d\n", |
| 37091 | expected_result, result, source1_f, source2_i); |
| 37092 | if (dumped == 0) cod_dump(gen_code); |
| 37093 | failed++; |
| 37094 | dumped++; |
| 37095 | } |
| 37096 | } |
| 37097 | } |
| 37098 | if (verbose) printf(" done\n"); |
| 37099 | cod_free_parse_context(context); |
| 37100 | cod_code_free(gen_code); |
| 37101 | } |
| 37102 | if ((only_run_test == NULL((void*)0)) || |
| 37103 | (strcmp(only_run_test, "f*u") == 0)) { |
| 37104 | int i, j; |
| 37105 | static char code[] = "{\n\ |
| 37106 | float a = p1;\n\ |
| 37107 | unsigned int b = p2;\n\ |
| 37108 | return a * b;\n\ |
| 37109 | }"; |
| 37110 | |
| 37111 | float (*proc)(float a, unsigned int b); |
| 37112 | cod_parse_context context = new_cod_parse_context(); |
| 37113 | int dumped = 0; |
| 37114 | |
| 37115 | cod_code gen_code; |
| 37116 | |
| 37117 | /* test for float * unsigned int */ |
| 37118 | if (verbose) printf("test for float * unsigned int"); |
| 37119 | |
| 37120 | cod_assoc_externs(context, externs); |
| 37121 | cod_parse_for_context(extern_string, context); |
| 37122 | |
| 37123 | cod_subroutine_declaration("float proc(float p1, unsigned int p2)", |
| 37124 | context); |
| 37125 | gen_code = cod_code_gen(code, context); |
| 37126 | proc = (float (*)(float, unsigned int))(long)gen_code->func; |
| 37127 | |
| 37128 | |
| 37129 | for (i=0 ; i < sizeof(src1f_vals)/sizeof(src1f_vals[0]) ; i++) { |
| 37130 | float source1_f = src1f_vals[i]; |
| 37131 | for (j=0 ; j < sizeof(src2u_vals)/sizeof(src2u_vals[0]) ; j++) { |
| 37132 | unsigned int source2_u = src2u_vals[j]; |
| 37133 | double range = 0.000001 * (fabs((double)source1_f * (double)source2_u)); |
| 37134 | float expected_result; |
| 37135 | float result; |
| 37136 | |
| 37137 | |
| 37138 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 37139 | |
| 37140 | expected_result = (float) (source1_f * source2_u); |
| 37141 | |
| 37142 | result = proc(source1_f, source2_u); |
| 37143 | range += 1.0; |
| 37144 | if ((result > (expected_result + range)) || (result < (expected_result - range))) { |
| 37145 | printf("Failed float * unsigned int test, expected %g, got %g, for %g * %u\n", |
| 37146 | expected_result, result, source1_f, source2_u); |
| 37147 | if (dumped == 0) cod_dump(gen_code); |
| 37148 | failed++; |
| 37149 | dumped++; |
| 37150 | } |
| 37151 | } |
| 37152 | } |
| 37153 | if (verbose) printf(" done\n"); |
| 37154 | cod_free_parse_context(context); |
| 37155 | cod_code_free(gen_code); |
| 37156 | } |
| 37157 | if ((only_run_test == NULL((void*)0)) || |
| 37158 | (strcmp(only_run_test, "f*ul") == 0)) { |
| 37159 | int i, j; |
| 37160 | static char code[] = "{\n\ |
| 37161 | float a = p1;\n\ |
| 37162 | unsigned long b = p2;\n\ |
| 37163 | return a * b;\n\ |
| 37164 | }"; |
| 37165 | |
| 37166 | float (*proc)(float a, unsigned long b); |
| 37167 | cod_parse_context context = new_cod_parse_context(); |
| 37168 | int dumped = 0; |
| 37169 | |
| 37170 | cod_code gen_code; |
| 37171 | |
| 37172 | /* test for float * unsigned long */ |
| 37173 | if (verbose) printf("test for float * unsigned long"); |
| 37174 | |
| 37175 | cod_assoc_externs(context, externs); |
| 37176 | cod_parse_for_context(extern_string, context); |
| 37177 | |
| 37178 | cod_subroutine_declaration("float proc(float p1, unsigned long p2)", |
| 37179 | context); |
| 37180 | gen_code = cod_code_gen(code, context); |
| 37181 | proc = (float (*)(float, unsigned long))(long)gen_code->func; |
| 37182 | |
| 37183 | |
| 37184 | for (i=0 ; i < sizeof(src1f_vals)/sizeof(src1f_vals[0]) ; i++) { |
| 37185 | float source1_f = src1f_vals[i]; |
| 37186 | for (j=0 ; j < sizeof(src2ul_vals)/sizeof(src2ul_vals[0]) ; j++) { |
| 37187 | unsigned long source2_ul = src2ul_vals[j]; |
| 37188 | double range = 0.000001 * (fabs((double)source1_f * (double)source2_ul)); |
| 37189 | float expected_result; |
| 37190 | float result; |
| 37191 | |
| 37192 | |
| 37193 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 37194 | |
| 37195 | expected_result = (float) (source1_f * source2_ul); |
| 37196 | |
| 37197 | result = proc(source1_f, source2_ul); |
| 37198 | range += 1.0; |
| 37199 | if ((result > (expected_result + range)) || (result < (expected_result - range))) { |
| 37200 | printf("Failed float * unsigned long test, expected %g, got %g, for %g * %lu\n", |
| 37201 | expected_result, result, source1_f, source2_ul); |
| 37202 | if (dumped == 0) cod_dump(gen_code); |
| 37203 | failed++; |
| 37204 | dumped++; |
| 37205 | } |
| 37206 | } |
| 37207 | } |
| 37208 | if (verbose) printf(" done\n"); |
| 37209 | cod_free_parse_context(context); |
| 37210 | cod_code_free(gen_code); |
| 37211 | } |
| 37212 | if ((only_run_test == NULL((void*)0)) || |
| 37213 | (strcmp(only_run_test, "f*l") == 0)) { |
| 37214 | int i, j; |
| 37215 | static char code[] = "{\n\ |
| 37216 | float a = p1;\n\ |
| 37217 | long b = p2;\n\ |
| 37218 | return a * b;\n\ |
| 37219 | }"; |
| 37220 | |
| 37221 | float (*proc)(float a, long b); |
| 37222 | cod_parse_context context = new_cod_parse_context(); |
| 37223 | int dumped = 0; |
| 37224 | |
| 37225 | cod_code gen_code; |
| 37226 | |
| 37227 | /* test for float * long */ |
| 37228 | if (verbose) printf("test for float * long"); |
| 37229 | |
| 37230 | cod_assoc_externs(context, externs); |
| 37231 | cod_parse_for_context(extern_string, context); |
| 37232 | |
| 37233 | cod_subroutine_declaration("float proc(float p1, long p2)", |
| 37234 | context); |
| 37235 | gen_code = cod_code_gen(code, context); |
| 37236 | proc = (float (*)(float, long))(long)gen_code->func; |
| 37237 | |
| 37238 | |
| 37239 | for (i=0 ; i < sizeof(src1f_vals)/sizeof(src1f_vals[0]) ; i++) { |
| 37240 | float source1_f = src1f_vals[i]; |
| 37241 | for (j=0 ; j < sizeof(src2l_vals)/sizeof(src2l_vals[0]) ; j++) { |
| 37242 | long source2_l = src2l_vals[j]; |
| 37243 | double range = 0.000001 * (fabs((double)source1_f * (double)source2_l)); |
| 37244 | float expected_result; |
| 37245 | float result; |
| 37246 | |
| 37247 | |
| 37248 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 37249 | |
| 37250 | expected_result = (float) (source1_f * source2_l); |
| 37251 | |
| 37252 | result = proc(source1_f, source2_l); |
| 37253 | range += 1.0; |
| 37254 | if ((result > (expected_result + range)) || (result < (expected_result - range))) { |
| 37255 | printf("Failed float * long test, expected %g, got %g, for %g * %ld\n", |
| 37256 | expected_result, result, source1_f, source2_l); |
| 37257 | if (dumped == 0) cod_dump(gen_code); |
| 37258 | failed++; |
| 37259 | dumped++; |
| 37260 | } |
| 37261 | } |
| 37262 | } |
| 37263 | if (verbose) printf(" done\n"); |
| 37264 | cod_free_parse_context(context); |
| 37265 | cod_code_free(gen_code); |
| 37266 | } |
| 37267 | if ((only_run_test == NULL((void*)0)) || |
| 37268 | (strcmp(only_run_test, "f*f") == 0)) { |
| 37269 | int i, j; |
| 37270 | static char code[] = "{\n\ |
| 37271 | float a = p1;\n\ |
| 37272 | float b = p2;\n\ |
| 37273 | return a * b;\n\ |
| 37274 | }"; |
| 37275 | |
| 37276 | float (*proc)(float a, float b); |
| 37277 | cod_parse_context context = new_cod_parse_context(); |
| 37278 | int dumped = 0; |
| 37279 | |
| 37280 | cod_code gen_code; |
| 37281 | |
| 37282 | /* test for float * float */ |
| 37283 | if (verbose) printf("test for float * float"); |
| 37284 | |
| 37285 | cod_assoc_externs(context, externs); |
| 37286 | cod_parse_for_context(extern_string, context); |
| 37287 | |
| 37288 | cod_subroutine_declaration("float proc(float p1, float p2)", |
| 37289 | context); |
| 37290 | gen_code = cod_code_gen(code, context); |
| 37291 | proc = (float (*)(float, float))(long)gen_code->func; |
| 37292 | |
| 37293 | |
| 37294 | for (i=0 ; i < sizeof(src1f_vals)/sizeof(src1f_vals[0]) ; i++) { |
| 37295 | float source1_f = src1f_vals[i]; |
| 37296 | for (j=0 ; j < sizeof(src2f_vals)/sizeof(src2f_vals[0]) ; j++) { |
| 37297 | float source2_f = src2f_vals[j]; |
| 37298 | double range = 0.000001 * (fabs((double)source1_f * (double)source2_f)); |
| 37299 | float expected_result; |
| 37300 | float result; |
| 37301 | |
| 37302 | |
| 37303 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 37304 | |
| 37305 | expected_result = (float) (source1_f * source2_f); |
| 37306 | |
| 37307 | result = proc(source1_f, source2_f); |
| 37308 | if ((result > (expected_result + range)) || (result < (expected_result - range))) { |
| 37309 | printf("Failed float * float test, expected %g, got %g, for %g * %g\n", |
| 37310 | expected_result, result, source1_f, source2_f); |
| 37311 | if (dumped == 0) cod_dump(gen_code); |
| 37312 | failed++; |
| 37313 | dumped++; |
| 37314 | } |
| 37315 | } |
| 37316 | } |
| 37317 | if (verbose) printf(" done\n"); |
| 37318 | cod_free_parse_context(context); |
| 37319 | cod_code_free(gen_code); |
| 37320 | } |
| 37321 | if ((only_run_test == NULL((void*)0)) || |
| 37322 | (strcmp(only_run_test, "f*d") == 0)) { |
| 37323 | int i, j; |
| 37324 | static char code[] = "{\n\ |
| 37325 | float a = p1;\n\ |
| 37326 | double b = p2;\n\ |
| 37327 | return a * b;\n\ |
| 37328 | }"; |
| 37329 | |
| 37330 | float (*proc)(float a, double b); |
| 37331 | cod_parse_context context = new_cod_parse_context(); |
| 37332 | int dumped = 0; |
| 37333 | |
| 37334 | cod_code gen_code; |
| 37335 | |
| 37336 | /* test for float * double */ |
| 37337 | if (verbose) printf("test for float * double"); |
| 37338 | |
| 37339 | cod_assoc_externs(context, externs); |
| 37340 | cod_parse_for_context(extern_string, context); |
| 37341 | |
| 37342 | cod_subroutine_declaration("float proc(float p1, double p2)", |
| 37343 | context); |
| 37344 | gen_code = cod_code_gen(code, context); |
| 37345 | proc = (float (*)(float, double))(long)gen_code->func; |
| 37346 | |
| 37347 | |
| 37348 | for (i=0 ; i < sizeof(src1f_vals)/sizeof(src1f_vals[0]) ; i++) { |
| 37349 | float source1_f = src1f_vals[i]; |
| 37350 | for (j=0 ; j < sizeof(src2d_vals)/sizeof(src2d_vals[0]) ; j++) { |
| 37351 | double source2_d = src2d_vals[j]; |
| 37352 | double range = 0.000001 * (fabs((double)source1_f * (double)source2_d)); |
| 37353 | float expected_result; |
| 37354 | float result; |
| 37355 | |
| 37356 | |
| 37357 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 37358 | |
| 37359 | expected_result = (float) (source1_f * source2_d); |
| 37360 | |
| 37361 | result = proc(source1_f, source2_d); |
| 37362 | range += 1.0; |
| 37363 | if ((result > (expected_result + range)) || (result < (expected_result - range))) { |
| 37364 | printf("Failed float * double test, expected %g, got %g, for %g * %g\n", |
| 37365 | expected_result, result, source1_f, source2_d); |
| 37366 | if (dumped == 0) cod_dump(gen_code); |
| 37367 | failed++; |
| 37368 | dumped++; |
| 37369 | } |
| 37370 | } |
| 37371 | } |
| 37372 | if (verbose) printf(" done\n"); |
| 37373 | cod_free_parse_context(context); |
| 37374 | cod_code_free(gen_code); |
| 37375 | } |
| 37376 | } |
| 37377 | void mult_d_tests() |
| 37378 | { |
| 37379 | if ((only_run_test == NULL((void*)0)) || |
| 37380 | (strcmp(only_run_test, "d*c") == 0)) { |
| 37381 | int i, j; |
| 37382 | static char code[] = "{\n\ |
| 37383 | double a = p1;\n\ |
| 37384 | signed char b = p2;\n\ |
| 37385 | return a * b;\n\ |
| 37386 | }"; |
| 37387 | |
| 37388 | double (*proc)(double a, signed char b); |
| 37389 | cod_parse_context context = new_cod_parse_context(); |
| 37390 | int dumped = 0; |
| 37391 | |
| 37392 | cod_code gen_code; |
| 37393 | |
| 37394 | /* test for double * signed char */ |
| 37395 | if (verbose) printf("test for double * signed char"); |
| 37396 | |
| 37397 | cod_assoc_externs(context, externs); |
| 37398 | cod_parse_for_context(extern_string, context); |
| 37399 | |
| 37400 | cod_subroutine_declaration("double proc(double p1, signed char p2)", |
| 37401 | context); |
| 37402 | gen_code = cod_code_gen(code, context); |
| 37403 | proc = (double (*)(double, signed char))(long)gen_code->func; |
| 37404 | |
| 37405 | |
| 37406 | for (i=0 ; i < sizeof(src1d_vals)/sizeof(src1d_vals[0]) ; i++) { |
| 37407 | double source1_d = src1d_vals[i]; |
| 37408 | for (j=0 ; j < sizeof(src2c_vals)/sizeof(src2c_vals[0]) ; j++) { |
| 37409 | signed char source2_c = src2c_vals[j]; |
| 37410 | |
| 37411 | double expected_result; |
| 37412 | double result; |
| 37413 | |
| 37414 | |
| 37415 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 37416 | |
| 37417 | expected_result = (double) (source1_d * source2_c); |
| 37418 | |
| 37419 | result = proc(source1_d, source2_c); |
| 37420 | if (expected_result != result) { |
| 37421 | printf("Failed double * signed char test, expected %g, got %g, for %g * %d\n", |
| 37422 | expected_result, result, source1_d, source2_c); |
| 37423 | if (dumped == 0) cod_dump(gen_code); |
| 37424 | failed++; |
| 37425 | dumped++; |
| 37426 | } |
| 37427 | } |
| 37428 | } |
| 37429 | if (verbose) printf(" done\n"); |
| 37430 | cod_free_parse_context(context); |
| 37431 | cod_code_free(gen_code); |
| 37432 | } |
| 37433 | if ((only_run_test == NULL((void*)0)) || |
| 37434 | (strcmp(only_run_test, "d*uc") == 0)) { |
| 37435 | int i, j; |
| 37436 | static char code[] = "{\n\ |
| 37437 | double a = p1;\n\ |
| 37438 | unsigned char b = p2;\n\ |
| 37439 | return a * b;\n\ |
| 37440 | }"; |
| 37441 | |
| 37442 | double (*proc)(double a, unsigned char b); |
| 37443 | cod_parse_context context = new_cod_parse_context(); |
| 37444 | int dumped = 0; |
| 37445 | |
| 37446 | cod_code gen_code; |
| 37447 | |
| 37448 | /* test for double * unsigned char */ |
| 37449 | if (verbose) printf("test for double * unsigned char"); |
| 37450 | |
| 37451 | cod_assoc_externs(context, externs); |
| 37452 | cod_parse_for_context(extern_string, context); |
| 37453 | |
| 37454 | cod_subroutine_declaration("double proc(double p1, unsigned char p2)", |
| 37455 | context); |
| 37456 | gen_code = cod_code_gen(code, context); |
| 37457 | proc = (double (*)(double, unsigned char))(long)gen_code->func; |
| 37458 | |
| 37459 | |
| 37460 | for (i=0 ; i < sizeof(src1d_vals)/sizeof(src1d_vals[0]) ; i++) { |
| 37461 | double source1_d = src1d_vals[i]; |
| 37462 | for (j=0 ; j < sizeof(src2uc_vals)/sizeof(src2uc_vals[0]) ; j++) { |
| 37463 | unsigned char source2_uc = src2uc_vals[j]; |
| 37464 | |
| 37465 | double expected_result; |
| 37466 | double result; |
| 37467 | |
| 37468 | |
| 37469 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 37470 | |
| 37471 | expected_result = (double) (source1_d * source2_uc); |
| 37472 | |
| 37473 | result = proc(source1_d, source2_uc); |
| 37474 | if (expected_result != result) { |
| 37475 | printf("Failed double * unsigned char test, expected %g, got %g, for %g * %u\n", |
| 37476 | expected_result, result, source1_d, source2_uc); |
| 37477 | if (dumped == 0) cod_dump(gen_code); |
| 37478 | failed++; |
| 37479 | dumped++; |
| 37480 | } |
| 37481 | } |
| 37482 | } |
| 37483 | if (verbose) printf(" done\n"); |
| 37484 | cod_free_parse_context(context); |
| 37485 | cod_code_free(gen_code); |
| 37486 | } |
| 37487 | if ((only_run_test == NULL((void*)0)) || |
| 37488 | (strcmp(only_run_test, "d*s") == 0)) { |
| 37489 | int i, j; |
| 37490 | static char code[] = "{\n\ |
| 37491 | double a = p1;\n\ |
| 37492 | short b = p2;\n\ |
| 37493 | return a * b;\n\ |
| 37494 | }"; |
| 37495 | |
| 37496 | double (*proc)(double a, short b); |
| 37497 | cod_parse_context context = new_cod_parse_context(); |
| 37498 | int dumped = 0; |
| 37499 | |
| 37500 | cod_code gen_code; |
| 37501 | |
| 37502 | /* test for double * short */ |
| 37503 | if (verbose) printf("test for double * short"); |
| 37504 | |
| 37505 | cod_assoc_externs(context, externs); |
| 37506 | cod_parse_for_context(extern_string, context); |
| 37507 | |
| 37508 | cod_subroutine_declaration("double proc(double p1, short p2)", |
| 37509 | context); |
| 37510 | gen_code = cod_code_gen(code, context); |
| 37511 | proc = (double (*)(double, short))(long)gen_code->func; |
| 37512 | |
| 37513 | |
| 37514 | for (i=0 ; i < sizeof(src1d_vals)/sizeof(src1d_vals[0]) ; i++) { |
| 37515 | double source1_d = src1d_vals[i]; |
| 37516 | for (j=0 ; j < sizeof(src2s_vals)/sizeof(src2s_vals[0]) ; j++) { |
| 37517 | short source2_s = src2s_vals[j]; |
| 37518 | |
| 37519 | double expected_result; |
| 37520 | double result; |
| 37521 | |
| 37522 | |
| 37523 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 37524 | |
| 37525 | expected_result = (double) (source1_d * source2_s); |
| 37526 | |
| 37527 | result = proc(source1_d, source2_s); |
| 37528 | if (expected_result != result) { |
| 37529 | printf("Failed double * short test, expected %g, got %g, for %g * %d\n", |
| 37530 | expected_result, result, source1_d, source2_s); |
| 37531 | if (dumped == 0) cod_dump(gen_code); |
| 37532 | failed++; |
| 37533 | dumped++; |
| 37534 | } |
| 37535 | } |
| 37536 | } |
| 37537 | if (verbose) printf(" done\n"); |
| 37538 | cod_free_parse_context(context); |
| 37539 | cod_code_free(gen_code); |
| 37540 | } |
| 37541 | if ((only_run_test == NULL((void*)0)) || |
| 37542 | (strcmp(only_run_test, "d*us") == 0)) { |
| 37543 | int i, j; |
| 37544 | static char code[] = "{\n\ |
| 37545 | double a = p1;\n\ |
| 37546 | unsigned short b = p2;\n\ |
| 37547 | return a * b;\n\ |
| 37548 | }"; |
| 37549 | |
| 37550 | double (*proc)(double a, unsigned short b); |
| 37551 | cod_parse_context context = new_cod_parse_context(); |
| 37552 | int dumped = 0; |
| 37553 | |
| 37554 | cod_code gen_code; |
| 37555 | |
| 37556 | /* test for double * unsigned short */ |
| 37557 | if (verbose) printf("test for double * unsigned short"); |
| 37558 | |
| 37559 | cod_assoc_externs(context, externs); |
| 37560 | cod_parse_for_context(extern_string, context); |
| 37561 | |
| 37562 | cod_subroutine_declaration("double proc(double p1, unsigned short p2)", |
| 37563 | context); |
| 37564 | gen_code = cod_code_gen(code, context); |
| 37565 | proc = (double (*)(double, unsigned short))(long)gen_code->func; |
| 37566 | |
| 37567 | |
| 37568 | for (i=0 ; i < sizeof(src1d_vals)/sizeof(src1d_vals[0]) ; i++) { |
| 37569 | double source1_d = src1d_vals[i]; |
| 37570 | for (j=0 ; j < sizeof(src2us_vals)/sizeof(src2us_vals[0]) ; j++) { |
| 37571 | unsigned short source2_us = src2us_vals[j]; |
| 37572 | |
| 37573 | double expected_result; |
| 37574 | double result; |
| 37575 | |
| 37576 | |
| 37577 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 37578 | |
| 37579 | expected_result = (double) (source1_d * source2_us); |
| 37580 | |
| 37581 | result = proc(source1_d, source2_us); |
| 37582 | if (expected_result != result) { |
| 37583 | printf("Failed double * unsigned short test, expected %g, got %g, for %g * %u\n", |
| 37584 | expected_result, result, source1_d, source2_us); |
| 37585 | if (dumped == 0) cod_dump(gen_code); |
| 37586 | failed++; |
| 37587 | dumped++; |
| 37588 | } |
| 37589 | } |
| 37590 | } |
| 37591 | if (verbose) printf(" done\n"); |
| 37592 | cod_free_parse_context(context); |
| 37593 | cod_code_free(gen_code); |
| 37594 | } |
| 37595 | if ((only_run_test == NULL((void*)0)) || |
| 37596 | (strcmp(only_run_test, "d*i") == 0)) { |
| 37597 | int i, j; |
| 37598 | static char code[] = "{\n\ |
| 37599 | double a = p1;\n\ |
| 37600 | int b = p2;\n\ |
| 37601 | return a * b;\n\ |
| 37602 | }"; |
| 37603 | |
| 37604 | double (*proc)(double a, int b); |
| 37605 | cod_parse_context context = new_cod_parse_context(); |
| 37606 | int dumped = 0; |
| 37607 | |
| 37608 | cod_code gen_code; |
| 37609 | |
| 37610 | /* test for double * int */ |
| 37611 | if (verbose) printf("test for double * int"); |
| 37612 | |
| 37613 | cod_assoc_externs(context, externs); |
| 37614 | cod_parse_for_context(extern_string, context); |
| 37615 | |
| 37616 | cod_subroutine_declaration("double proc(double p1, int p2)", |
| 37617 | context); |
| 37618 | gen_code = cod_code_gen(code, context); |
| 37619 | proc = (double (*)(double, int))(long)gen_code->func; |
| 37620 | |
| 37621 | |
| 37622 | for (i=0 ; i < sizeof(src1d_vals)/sizeof(src1d_vals[0]) ; i++) { |
| 37623 | double source1_d = src1d_vals[i]; |
| 37624 | for (j=0 ; j < sizeof(src2i_vals)/sizeof(src2i_vals[0]) ; j++) { |
| 37625 | int source2_i = src2i_vals[j]; |
| 37626 | |
| 37627 | double expected_result; |
| 37628 | double result; |
| 37629 | |
| 37630 | |
| 37631 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 37632 | |
| 37633 | expected_result = (double) (source1_d * source2_i); |
| 37634 | |
| 37635 | result = proc(source1_d, source2_i); |
| 37636 | if (expected_result != result) { |
| 37637 | printf("Failed double * int test, expected %g, got %g, for %g * %d\n", |
| 37638 | expected_result, result, source1_d, source2_i); |
| 37639 | if (dumped == 0) cod_dump(gen_code); |
| 37640 | failed++; |
| 37641 | dumped++; |
| 37642 | } |
| 37643 | } |
| 37644 | } |
| 37645 | if (verbose) printf(" done\n"); |
| 37646 | cod_free_parse_context(context); |
| 37647 | cod_code_free(gen_code); |
| 37648 | } |
| 37649 | if ((only_run_test == NULL((void*)0)) || |
| 37650 | (strcmp(only_run_test, "d*u") == 0)) { |
| 37651 | int i, j; |
| 37652 | static char code[] = "{\n\ |
| 37653 | double a = p1;\n\ |
| 37654 | unsigned int b = p2;\n\ |
| 37655 | return a * b;\n\ |
| 37656 | }"; |
| 37657 | |
| 37658 | double (*proc)(double a, unsigned int b); |
| 37659 | cod_parse_context context = new_cod_parse_context(); |
| 37660 | int dumped = 0; |
| 37661 | |
| 37662 | cod_code gen_code; |
| 37663 | |
| 37664 | /* test for double * unsigned int */ |
| 37665 | if (verbose) printf("test for double * unsigned int"); |
| 37666 | |
| 37667 | cod_assoc_externs(context, externs); |
| 37668 | cod_parse_for_context(extern_string, context); |
| 37669 | |
| 37670 | cod_subroutine_declaration("double proc(double p1, unsigned int p2)", |
| 37671 | context); |
| 37672 | gen_code = cod_code_gen(code, context); |
| 37673 | proc = (double (*)(double, unsigned int))(long)gen_code->func; |
| 37674 | |
| 37675 | |
| 37676 | for (i=0 ; i < sizeof(src1d_vals)/sizeof(src1d_vals[0]) ; i++) { |
| 37677 | double source1_d = src1d_vals[i]; |
| 37678 | for (j=0 ; j < sizeof(src2u_vals)/sizeof(src2u_vals[0]) ; j++) { |
| 37679 | unsigned int source2_u = src2u_vals[j]; |
| 37680 | |
| 37681 | double expected_result; |
| 37682 | double result; |
| 37683 | |
| 37684 | |
| 37685 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 37686 | |
| 37687 | expected_result = (double) (source1_d * source2_u); |
| 37688 | |
| 37689 | result = proc(source1_d, source2_u); |
| 37690 | if (expected_result != result) { |
| 37691 | printf("Failed double * unsigned int test, expected %g, got %g, for %g * %u\n", |
| 37692 | expected_result, result, source1_d, source2_u); |
| 37693 | if (dumped == 0) cod_dump(gen_code); |
| 37694 | failed++; |
| 37695 | dumped++; |
| 37696 | } |
| 37697 | } |
| 37698 | } |
| 37699 | if (verbose) printf(" done\n"); |
| 37700 | cod_free_parse_context(context); |
| 37701 | cod_code_free(gen_code); |
| 37702 | } |
| 37703 | if ((only_run_test == NULL((void*)0)) || |
| 37704 | (strcmp(only_run_test, "d*ul") == 0)) { |
| 37705 | int i, j; |
| 37706 | static char code[] = "{\n\ |
| 37707 | double a = p1;\n\ |
| 37708 | unsigned long b = p2;\n\ |
| 37709 | return a * b;\n\ |
| 37710 | }"; |
| 37711 | |
| 37712 | double (*proc)(double a, unsigned long b); |
| 37713 | cod_parse_context context = new_cod_parse_context(); |
| 37714 | int dumped = 0; |
| 37715 | |
| 37716 | cod_code gen_code; |
| 37717 | |
| 37718 | /* test for double * unsigned long */ |
| 37719 | if (verbose) printf("test for double * unsigned long"); |
| 37720 | |
| 37721 | cod_assoc_externs(context, externs); |
| 37722 | cod_parse_for_context(extern_string, context); |
| 37723 | |
| 37724 | cod_subroutine_declaration("double proc(double p1, unsigned long p2)", |
| 37725 | context); |
| 37726 | gen_code = cod_code_gen(code, context); |
| 37727 | proc = (double (*)(double, unsigned long))(long)gen_code->func; |
| 37728 | |
| 37729 | |
| 37730 | for (i=0 ; i < sizeof(src1d_vals)/sizeof(src1d_vals[0]) ; i++) { |
| 37731 | double source1_d = src1d_vals[i]; |
| 37732 | for (j=0 ; j < sizeof(src2ul_vals)/sizeof(src2ul_vals[0]) ; j++) { |
| 37733 | unsigned long source2_ul = src2ul_vals[j]; |
| 37734 | |
| 37735 | double expected_result; |
| 37736 | double result; |
| 37737 | |
| 37738 | |
| 37739 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 37740 | |
| 37741 | expected_result = (double) (source1_d * source2_ul); |
| 37742 | |
| 37743 | result = proc(source1_d, source2_ul); |
| 37744 | if (expected_result != result) { |
| 37745 | printf("Failed double * unsigned long test, expected %g, got %g, for %g * %lu\n", |
| 37746 | expected_result, result, source1_d, source2_ul); |
| 37747 | if (dumped == 0) cod_dump(gen_code); |
| 37748 | failed++; |
| 37749 | dumped++; |
| 37750 | } |
| 37751 | } |
| 37752 | } |
| 37753 | if (verbose) printf(" done\n"); |
| 37754 | cod_free_parse_context(context); |
| 37755 | cod_code_free(gen_code); |
| 37756 | } |
| 37757 | if ((only_run_test == NULL((void*)0)) || |
| 37758 | (strcmp(only_run_test, "d*l") == 0)) { |
| 37759 | int i, j; |
| 37760 | static char code[] = "{\n\ |
| 37761 | double a = p1;\n\ |
| 37762 | long b = p2;\n\ |
| 37763 | return a * b;\n\ |
| 37764 | }"; |
| 37765 | |
| 37766 | double (*proc)(double a, long b); |
| 37767 | cod_parse_context context = new_cod_parse_context(); |
| 37768 | int dumped = 0; |
| 37769 | |
| 37770 | cod_code gen_code; |
| 37771 | |
| 37772 | /* test for double * long */ |
| 37773 | if (verbose) printf("test for double * long"); |
| 37774 | |
| 37775 | cod_assoc_externs(context, externs); |
| 37776 | cod_parse_for_context(extern_string, context); |
| 37777 | |
| 37778 | cod_subroutine_declaration("double proc(double p1, long p2)", |
| 37779 | context); |
| 37780 | gen_code = cod_code_gen(code, context); |
| 37781 | proc = (double (*)(double, long))(long)gen_code->func; |
| 37782 | |
| 37783 | |
| 37784 | for (i=0 ; i < sizeof(src1d_vals)/sizeof(src1d_vals[0]) ; i++) { |
| 37785 | double source1_d = src1d_vals[i]; |
| 37786 | for (j=0 ; j < sizeof(src2l_vals)/sizeof(src2l_vals[0]) ; j++) { |
| 37787 | long source2_l = src2l_vals[j]; |
| 37788 | |
| 37789 | double expected_result; |
| 37790 | double result; |
| 37791 | |
| 37792 | |
| 37793 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 37794 | |
| 37795 | expected_result = (double) (source1_d * source2_l); |
| 37796 | |
| 37797 | result = proc(source1_d, source2_l); |
| 37798 | if (expected_result != result) { |
| 37799 | printf("Failed double * long test, expected %g, got %g, for %g * %ld\n", |
| 37800 | expected_result, result, source1_d, source2_l); |
| 37801 | if (dumped == 0) cod_dump(gen_code); |
| 37802 | failed++; |
| 37803 | dumped++; |
| 37804 | } |
| 37805 | } |
| 37806 | } |
| 37807 | if (verbose) printf(" done\n"); |
| 37808 | cod_free_parse_context(context); |
| 37809 | cod_code_free(gen_code); |
| 37810 | } |
| 37811 | if ((only_run_test == NULL((void*)0)) || |
| 37812 | (strcmp(only_run_test, "d*f") == 0)) { |
| 37813 | int i, j; |
| 37814 | static char code[] = "{\n\ |
| 37815 | double a = p1;\n\ |
| 37816 | float b = p2;\n\ |
| 37817 | return a * b;\n\ |
| 37818 | }"; |
| 37819 | |
| 37820 | double (*proc)(double a, float b); |
| 37821 | cod_parse_context context = new_cod_parse_context(); |
| 37822 | int dumped = 0; |
| 37823 | |
| 37824 | cod_code gen_code; |
| 37825 | |
| 37826 | /* test for double * float */ |
| 37827 | if (verbose) printf("test for double * float"); |
| 37828 | |
| 37829 | cod_assoc_externs(context, externs); |
| 37830 | cod_parse_for_context(extern_string, context); |
| 37831 | |
| 37832 | cod_subroutine_declaration("double proc(double p1, float p2)", |
| 37833 | context); |
| 37834 | gen_code = cod_code_gen(code, context); |
| 37835 | proc = (double (*)(double, float))(long)gen_code->func; |
| 37836 | |
| 37837 | |
| 37838 | for (i=0 ; i < sizeof(src1d_vals)/sizeof(src1d_vals[0]) ; i++) { |
| 37839 | double source1_d = src1d_vals[i]; |
| 37840 | for (j=0 ; j < sizeof(src2f_vals)/sizeof(src2f_vals[0]) ; j++) { |
| 37841 | float source2_f = src2f_vals[j]; |
| 37842 | double range = 0.000001 * (fabs((double)source1_d * (double)source2_f)); |
| 37843 | double expected_result; |
| 37844 | double result; |
| 37845 | |
| 37846 | |
| 37847 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 37848 | |
| 37849 | expected_result = (double) (source1_d * source2_f); |
| 37850 | |
| 37851 | result = proc(source1_d, source2_f); |
| 37852 | range += 1.0; |
| 37853 | if ((result > (expected_result + range)) || (result < (expected_result - range))) { |
| 37854 | printf("Failed double * float test, expected %g, got %g, for %g * %g\n", |
| 37855 | expected_result, result, source1_d, source2_f); |
| 37856 | if (dumped == 0) cod_dump(gen_code); |
| 37857 | failed++; |
| 37858 | dumped++; |
| 37859 | } |
| 37860 | } |
| 37861 | } |
| 37862 | if (verbose) printf(" done\n"); |
| 37863 | cod_free_parse_context(context); |
| 37864 | cod_code_free(gen_code); |
| 37865 | } |
| 37866 | if ((only_run_test == NULL((void*)0)) || |
| 37867 | (strcmp(only_run_test, "d*d") == 0)) { |
| 37868 | int i, j; |
| 37869 | static char code[] = "{\n\ |
| 37870 | double a = p1;\n\ |
| 37871 | double b = p2;\n\ |
| 37872 | return a * b;\n\ |
| 37873 | }"; |
| 37874 | |
| 37875 | double (*proc)(double a, double b); |
| 37876 | cod_parse_context context = new_cod_parse_context(); |
| 37877 | int dumped = 0; |
| 37878 | |
| 37879 | cod_code gen_code; |
| 37880 | |
| 37881 | /* test for double * double */ |
| 37882 | if (verbose) printf("test for double * double"); |
| 37883 | |
| 37884 | cod_assoc_externs(context, externs); |
| 37885 | cod_parse_for_context(extern_string, context); |
| 37886 | |
| 37887 | cod_subroutine_declaration("double proc(double p1, double p2)", |
| 37888 | context); |
| 37889 | gen_code = cod_code_gen(code, context); |
| 37890 | proc = (double (*)(double, double))(long)gen_code->func; |
| 37891 | |
| 37892 | |
| 37893 | for (i=0 ; i < sizeof(src1d_vals)/sizeof(src1d_vals[0]) ; i++) { |
| 37894 | double source1_d = src1d_vals[i]; |
| 37895 | for (j=0 ; j < sizeof(src2d_vals)/sizeof(src2d_vals[0]) ; j++) { |
| 37896 | double source2_d = src2d_vals[j]; |
| 37897 | |
| 37898 | double expected_result; |
| 37899 | double result; |
| 37900 | |
| 37901 | |
| 37902 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 37903 | |
| 37904 | expected_result = (double) (source1_d * source2_d); |
| 37905 | |
| 37906 | result = proc(source1_d, source2_d); |
| 37907 | if (expected_result != result) { |
| 37908 | printf("Failed double * double test, expected %g, got %g, for %g * %g\n", |
| 37909 | expected_result, result, source1_d, source2_d); |
| 37910 | if (dumped == 0) cod_dump(gen_code); |
| 37911 | failed++; |
| 37912 | dumped++; |
| 37913 | } |
| 37914 | } |
| 37915 | } |
| 37916 | if (verbose) printf(" done\n"); |
| 37917 | cod_free_parse_context(context); |
| 37918 | cod_code_free(gen_code); |
| 37919 | } |
| 37920 | } |
| 37921 | void div_c_tests() |
| 37922 | { |
| 37923 | if ((only_run_test == NULL((void*)0)) || |
| 37924 | (strcmp(only_run_test, "c/c") == 0)) { |
| 37925 | int i, j; |
| 37926 | static char code[] = "{\n\ |
| 37927 | signed char a = p1;\n\ |
| 37928 | signed char b = p2;\n\ |
| 37929 | return a / b;\n\ |
| 37930 | }"; |
| 37931 | |
| 37932 | signed char (*proc)(signed char a, signed char b); |
| 37933 | cod_parse_context context = new_cod_parse_context(); |
| 37934 | int dumped = 0; |
| 37935 | |
| 37936 | cod_code gen_code; |
| 37937 | |
| 37938 | /* test for signed char / signed char */ |
| 37939 | if (verbose) printf("test for signed char / signed char"); |
| 37940 | |
| 37941 | cod_assoc_externs(context, externs); |
| 37942 | cod_parse_for_context(extern_string, context); |
| 37943 | |
| 37944 | cod_subroutine_declaration("signed char proc(signed char p1, signed char p2)", |
| 37945 | context); |
| 37946 | gen_code = cod_code_gen(code, context); |
| 37947 | proc = (signed char (*)(signed char, signed char))(long)gen_code->func; |
| 37948 | |
| 37949 | |
| 37950 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 37951 | signed char source1_c = src1c_vals[i]; |
| 37952 | for (j=0 ; j < sizeof(src2c_vals)/sizeof(src2c_vals[0]) ; j++) { |
| 37953 | signed char source2_c = src2c_vals[j]; |
| 37954 | |
| 37955 | signed char expected_result; |
| 37956 | signed char result; |
| 37957 | |
| 37958 | if (source2_c == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip128;} |
| 37959 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 37960 | |
| 37961 | expected_result = (signed char) (source1_c / source2_c); |
| 37962 | |
| 37963 | result = proc(source1_c, source2_c); |
| 37964 | if (expected_result != result) { |
| 37965 | printf("Failed signed char / signed char test, expected %d, got %d, for %d / %d\n", |
| 37966 | expected_result, result, source1_c, source2_c); |
| 37967 | if (dumped == 0) cod_dump(gen_code); |
| 37968 | failed++; |
| 37969 | dumped++; |
| 37970 | } |
| 37971 | skip128: ; |
| 37972 | } |
| 37973 | } |
| 37974 | if (verbose) printf(" done\n"); |
| 37975 | cod_free_parse_context(context); |
| 37976 | cod_code_free(gen_code); |
| 37977 | } |
| 37978 | if ((only_run_test == NULL((void*)0)) || |
| 37979 | (strcmp(only_run_test, "c/uc") == 0)) { |
| 37980 | int i, j; |
| 37981 | static char code[] = "{\n\ |
| 37982 | signed char a = p1;\n\ |
| 37983 | unsigned char b = p2;\n\ |
| 37984 | return a / b;\n\ |
| 37985 | }"; |
| 37986 | |
| 37987 | signed char (*proc)(signed char a, unsigned char b); |
| 37988 | cod_parse_context context = new_cod_parse_context(); |
| 37989 | int dumped = 0; |
| 37990 | |
| 37991 | cod_code gen_code; |
| 37992 | |
| 37993 | /* test for signed char / unsigned char */ |
| 37994 | if (verbose) printf("test for signed char / unsigned char"); |
| 37995 | |
| 37996 | cod_assoc_externs(context, externs); |
| 37997 | cod_parse_for_context(extern_string, context); |
| 37998 | |
| 37999 | cod_subroutine_declaration("signed char proc(signed char p1, unsigned char p2)", |
| 38000 | context); |
| 38001 | gen_code = cod_code_gen(code, context); |
| 38002 | proc = (signed char (*)(signed char, unsigned char))(long)gen_code->func; |
| 38003 | |
| 38004 | |
| 38005 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 38006 | signed char source1_c = src1c_vals[i]; |
| 38007 | for (j=0 ; j < sizeof(src2uc_vals)/sizeof(src2uc_vals[0]) ; j++) { |
| 38008 | unsigned char source2_uc = src2uc_vals[j]; |
| 38009 | |
| 38010 | signed char expected_result; |
| 38011 | signed char result; |
| 38012 | |
| 38013 | if (source2_uc == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip129;} |
| 38014 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 38015 | |
| 38016 | expected_result = (signed char) (source1_c / source2_uc); |
| 38017 | |
| 38018 | result = proc(source1_c, source2_uc); |
| 38019 | if (expected_result != result) { |
| 38020 | printf("Failed signed char / unsigned char test, expected %d, got %d, for %d / %u\n", |
| 38021 | expected_result, result, source1_c, source2_uc); |
| 38022 | if (dumped == 0) cod_dump(gen_code); |
| 38023 | failed++; |
| 38024 | dumped++; |
| 38025 | } |
| 38026 | skip129: ; |
| 38027 | } |
| 38028 | } |
| 38029 | if (verbose) printf(" done\n"); |
| 38030 | cod_free_parse_context(context); |
| 38031 | cod_code_free(gen_code); |
| 38032 | } |
| 38033 | if ((only_run_test == NULL((void*)0)) || |
| 38034 | (strcmp(only_run_test, "c/s") == 0)) { |
| 38035 | int i, j; |
| 38036 | static char code[] = "{\n\ |
| 38037 | signed char a = p1;\n\ |
| 38038 | short b = p2;\n\ |
| 38039 | return a / b;\n\ |
| 38040 | }"; |
| 38041 | |
| 38042 | signed char (*proc)(signed char a, short b); |
| 38043 | cod_parse_context context = new_cod_parse_context(); |
| 38044 | int dumped = 0; |
| 38045 | |
| 38046 | cod_code gen_code; |
| 38047 | |
| 38048 | /* test for signed char / short */ |
| 38049 | if (verbose) printf("test for signed char / short"); |
| 38050 | |
| 38051 | cod_assoc_externs(context, externs); |
| 38052 | cod_parse_for_context(extern_string, context); |
| 38053 | |
| 38054 | cod_subroutine_declaration("signed char proc(signed char p1, short p2)", |
| 38055 | context); |
| 38056 | gen_code = cod_code_gen(code, context); |
| 38057 | proc = (signed char (*)(signed char, short))(long)gen_code->func; |
| 38058 | |
| 38059 | |
| 38060 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 38061 | signed char source1_c = src1c_vals[i]; |
| 38062 | for (j=0 ; j < sizeof(src2s_vals)/sizeof(src2s_vals[0]) ; j++) { |
| 38063 | short source2_s = src2s_vals[j]; |
| 38064 | |
| 38065 | signed char expected_result; |
| 38066 | signed char result; |
| 38067 | |
| 38068 | if (source2_s == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip130;} |
| 38069 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 38070 | |
| 38071 | expected_result = (signed char) (source1_c / source2_s); |
| 38072 | |
| 38073 | result = proc(source1_c, source2_s); |
| 38074 | if (expected_result != result) { |
| 38075 | printf("Failed signed char / short test, expected %d, got %d, for %d / %d\n", |
| 38076 | expected_result, result, source1_c, source2_s); |
| 38077 | if (dumped == 0) cod_dump(gen_code); |
| 38078 | failed++; |
| 38079 | dumped++; |
| 38080 | } |
| 38081 | skip130: ; |
| 38082 | } |
| 38083 | } |
| 38084 | if (verbose) printf(" done\n"); |
| 38085 | cod_free_parse_context(context); |
| 38086 | cod_code_free(gen_code); |
| 38087 | } |
| 38088 | if ((only_run_test == NULL((void*)0)) || |
| 38089 | (strcmp(only_run_test, "c/us") == 0)) { |
| 38090 | int i, j; |
| 38091 | static char code[] = "{\n\ |
| 38092 | signed char a = p1;\n\ |
| 38093 | unsigned short b = p2;\n\ |
| 38094 | return a / b;\n\ |
| 38095 | }"; |
| 38096 | |
| 38097 | signed char (*proc)(signed char a, unsigned short b); |
| 38098 | cod_parse_context context = new_cod_parse_context(); |
| 38099 | int dumped = 0; |
| 38100 | |
| 38101 | cod_code gen_code; |
| 38102 | |
| 38103 | /* test for signed char / unsigned short */ |
| 38104 | if (verbose) printf("test for signed char / unsigned short"); |
| 38105 | |
| 38106 | cod_assoc_externs(context, externs); |
| 38107 | cod_parse_for_context(extern_string, context); |
| 38108 | |
| 38109 | cod_subroutine_declaration("signed char proc(signed char p1, unsigned short p2)", |
| 38110 | context); |
| 38111 | gen_code = cod_code_gen(code, context); |
| 38112 | proc = (signed char (*)(signed char, unsigned short))(long)gen_code->func; |
| 38113 | |
| 38114 | |
| 38115 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 38116 | signed char source1_c = src1c_vals[i]; |
| 38117 | for (j=0 ; j < sizeof(src2us_vals)/sizeof(src2us_vals[0]) ; j++) { |
| 38118 | unsigned short source2_us = src2us_vals[j]; |
| 38119 | |
| 38120 | signed char expected_result; |
| 38121 | signed char result; |
| 38122 | |
| 38123 | if (source2_us == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip131;} |
| 38124 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 38125 | |
| 38126 | expected_result = (signed char) (source1_c / source2_us); |
| 38127 | |
| 38128 | result = proc(source1_c, source2_us); |
| 38129 | if (expected_result != result) { |
| 38130 | printf("Failed signed char / unsigned short test, expected %d, got %d, for %d / %u\n", |
| 38131 | expected_result, result, source1_c, source2_us); |
| 38132 | if (dumped == 0) cod_dump(gen_code); |
| 38133 | failed++; |
| 38134 | dumped++; |
| 38135 | } |
| 38136 | skip131: ; |
| 38137 | } |
| 38138 | } |
| 38139 | if (verbose) printf(" done\n"); |
| 38140 | cod_free_parse_context(context); |
| 38141 | cod_code_free(gen_code); |
| 38142 | } |
| 38143 | if ((only_run_test == NULL((void*)0)) || |
| 38144 | (strcmp(only_run_test, "c/i") == 0)) { |
| 38145 | int i, j; |
| 38146 | static char code[] = "{\n\ |
| 38147 | signed char a = p1;\n\ |
| 38148 | int b = p2;\n\ |
| 38149 | return a / b;\n\ |
| 38150 | }"; |
| 38151 | |
| 38152 | signed char (*proc)(signed char a, int b); |
| 38153 | cod_parse_context context = new_cod_parse_context(); |
| 38154 | int dumped = 0; |
| 38155 | |
| 38156 | cod_code gen_code; |
| 38157 | |
| 38158 | /* test for signed char / int */ |
| 38159 | if (verbose) printf("test for signed char / int"); |
| 38160 | |
| 38161 | cod_assoc_externs(context, externs); |
| 38162 | cod_parse_for_context(extern_string, context); |
| 38163 | |
| 38164 | cod_subroutine_declaration("signed char proc(signed char p1, int p2)", |
| 38165 | context); |
| 38166 | gen_code = cod_code_gen(code, context); |
| 38167 | proc = (signed char (*)(signed char, int))(long)gen_code->func; |
| 38168 | |
| 38169 | |
| 38170 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 38171 | signed char source1_c = src1c_vals[i]; |
| 38172 | for (j=0 ; j < sizeof(src2i_vals)/sizeof(src2i_vals[0]) ; j++) { |
| 38173 | int source2_i = src2i_vals[j]; |
| 38174 | |
| 38175 | signed char expected_result; |
| 38176 | signed char result; |
| 38177 | |
| 38178 | if (source2_i == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip132;} |
| 38179 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 38180 | |
| 38181 | expected_result = (signed char) (source1_c / source2_i); |
| 38182 | |
| 38183 | result = proc(source1_c, source2_i); |
| 38184 | if (expected_result != result) { |
| 38185 | printf("Failed signed char / int test, expected %d, got %d, for %d / %d\n", |
| 38186 | expected_result, result, source1_c, source2_i); |
| 38187 | if (dumped == 0) cod_dump(gen_code); |
| 38188 | failed++; |
| 38189 | dumped++; |
| 38190 | } |
| 38191 | skip132: ; |
| 38192 | } |
| 38193 | } |
| 38194 | if (verbose) printf(" done\n"); |
| 38195 | cod_free_parse_context(context); |
| 38196 | cod_code_free(gen_code); |
| 38197 | } |
| 38198 | if ((only_run_test == NULL((void*)0)) || |
| 38199 | (strcmp(only_run_test, "c/u") == 0)) { |
| 38200 | int i, j; |
| 38201 | static char code[] = "{\n\ |
| 38202 | signed char a = p1;\n\ |
| 38203 | unsigned int b = p2;\n\ |
| 38204 | return a / b;\n\ |
| 38205 | }"; |
| 38206 | |
| 38207 | signed char (*proc)(signed char a, unsigned int b); |
| 38208 | cod_parse_context context = new_cod_parse_context(); |
| 38209 | int dumped = 0; |
| 38210 | |
| 38211 | cod_code gen_code; |
| 38212 | |
| 38213 | /* test for signed char / unsigned int */ |
| 38214 | if (verbose) printf("test for signed char / unsigned int"); |
| 38215 | |
| 38216 | cod_assoc_externs(context, externs); |
| 38217 | cod_parse_for_context(extern_string, context); |
| 38218 | |
| 38219 | cod_subroutine_declaration("signed char proc(signed char p1, unsigned int p2)", |
| 38220 | context); |
| 38221 | gen_code = cod_code_gen(code, context); |
| 38222 | proc = (signed char (*)(signed char, unsigned int))(long)gen_code->func; |
| 38223 | |
| 38224 | |
| 38225 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 38226 | signed char source1_c = src1c_vals[i]; |
| 38227 | for (j=0 ; j < sizeof(src2u_vals)/sizeof(src2u_vals[0]) ; j++) { |
| 38228 | unsigned int source2_u = src2u_vals[j]; |
| 38229 | |
| 38230 | signed char expected_result; |
| 38231 | signed char result; |
| 38232 | |
| 38233 | if (source2_u == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip133;} |
| 38234 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 38235 | |
| 38236 | expected_result = (signed char) (source1_c / source2_u); |
| 38237 | |
| 38238 | result = proc(source1_c, source2_u); |
| 38239 | if (expected_result != result) { |
| 38240 | printf("Failed signed char / unsigned int test, expected %d, got %d, for %d / %u\n", |
| 38241 | expected_result, result, source1_c, source2_u); |
| 38242 | if (dumped == 0) cod_dump(gen_code); |
| 38243 | failed++; |
| 38244 | dumped++; |
| 38245 | } |
| 38246 | skip133: ; |
| 38247 | } |
| 38248 | } |
| 38249 | if (verbose) printf(" done\n"); |
| 38250 | cod_free_parse_context(context); |
| 38251 | cod_code_free(gen_code); |
| 38252 | } |
| 38253 | if ((only_run_test == NULL((void*)0)) || |
| 38254 | (strcmp(only_run_test, "c/ul") == 0)) { |
| 38255 | int i, j; |
| 38256 | static char code[] = "{\n\ |
| 38257 | signed char a = p1;\n\ |
| 38258 | unsigned long b = p2;\n\ |
| 38259 | return a / b;\n\ |
| 38260 | }"; |
| 38261 | |
| 38262 | signed char (*proc)(signed char a, unsigned long b); |
| 38263 | cod_parse_context context = new_cod_parse_context(); |
| 38264 | int dumped = 0; |
| 38265 | |
| 38266 | cod_code gen_code; |
| 38267 | |
| 38268 | /* test for signed char / unsigned long */ |
| 38269 | if (verbose) printf("test for signed char / unsigned long"); |
| 38270 | |
| 38271 | cod_assoc_externs(context, externs); |
| 38272 | cod_parse_for_context(extern_string, context); |
| 38273 | |
| 38274 | cod_subroutine_declaration("signed char proc(signed char p1, unsigned long p2)", |
| 38275 | context); |
| 38276 | gen_code = cod_code_gen(code, context); |
| 38277 | proc = (signed char (*)(signed char, unsigned long))(long)gen_code->func; |
| 38278 | |
| 38279 | |
| 38280 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 38281 | signed char source1_c = src1c_vals[i]; |
| 38282 | for (j=0 ; j < sizeof(src2ul_vals)/sizeof(src2ul_vals[0]) ; j++) { |
| 38283 | unsigned long source2_ul = src2ul_vals[j]; |
| 38284 | |
| 38285 | signed char expected_result; |
| 38286 | signed char result; |
| 38287 | |
| 38288 | if (source2_ul == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip134;} |
| 38289 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 38290 | |
| 38291 | expected_result = (signed char) (source1_c / source2_ul); |
| 38292 | |
| 38293 | result = proc(source1_c, source2_ul); |
| 38294 | if (expected_result != result) { |
| 38295 | printf("Failed signed char / unsigned long test, expected %d, got %d, for %d / %lu\n", |
| 38296 | expected_result, result, source1_c, source2_ul); |
| 38297 | if (dumped == 0) cod_dump(gen_code); |
| 38298 | failed++; |
| 38299 | dumped++; |
| 38300 | } |
| 38301 | skip134: ; |
| 38302 | } |
| 38303 | } |
| 38304 | if (verbose) printf(" done\n"); |
| 38305 | cod_free_parse_context(context); |
| 38306 | cod_code_free(gen_code); |
| 38307 | } |
| 38308 | if ((only_run_test == NULL((void*)0)) || |
| 38309 | (strcmp(only_run_test, "c/l") == 0)) { |
| 38310 | int i, j; |
| 38311 | static char code[] = "{\n\ |
| 38312 | signed char a = p1;\n\ |
| 38313 | long b = p2;\n\ |
| 38314 | return a / b;\n\ |
| 38315 | }"; |
| 38316 | |
| 38317 | signed char (*proc)(signed char a, long b); |
| 38318 | cod_parse_context context = new_cod_parse_context(); |
| 38319 | int dumped = 0; |
| 38320 | |
| 38321 | cod_code gen_code; |
| 38322 | |
| 38323 | /* test for signed char / long */ |
| 38324 | if (verbose) printf("test for signed char / long"); |
| 38325 | |
| 38326 | cod_assoc_externs(context, externs); |
| 38327 | cod_parse_for_context(extern_string, context); |
| 38328 | |
| 38329 | cod_subroutine_declaration("signed char proc(signed char p1, long p2)", |
| 38330 | context); |
| 38331 | gen_code = cod_code_gen(code, context); |
| 38332 | proc = (signed char (*)(signed char, long))(long)gen_code->func; |
| 38333 | |
| 38334 | |
| 38335 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 38336 | signed char source1_c = src1c_vals[i]; |
| 38337 | for (j=0 ; j < sizeof(src2l_vals)/sizeof(src2l_vals[0]) ; j++) { |
| 38338 | long source2_l = src2l_vals[j]; |
| 38339 | |
| 38340 | signed char expected_result; |
| 38341 | signed char result; |
| 38342 | |
| 38343 | if (source2_l == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip135;} |
| 38344 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 38345 | |
| 38346 | expected_result = (signed char) (source1_c / source2_l); |
| 38347 | |
| 38348 | result = proc(source1_c, source2_l); |
| 38349 | if (expected_result != result) { |
| 38350 | printf("Failed signed char / long test, expected %d, got %d, for %d / %ld\n", |
| 38351 | expected_result, result, source1_c, source2_l); |
| 38352 | if (dumped == 0) cod_dump(gen_code); |
| 38353 | failed++; |
| 38354 | dumped++; |
| 38355 | } |
| 38356 | skip135: ; |
| 38357 | } |
| 38358 | } |
| 38359 | if (verbose) printf(" done\n"); |
| 38360 | cod_free_parse_context(context); |
| 38361 | cod_code_free(gen_code); |
| 38362 | } |
| 38363 | if ((only_run_test == NULL((void*)0)) || |
| 38364 | (strcmp(only_run_test, "c/f") == 0)) { |
| 38365 | int i, j; |
| 38366 | static char code[] = "{\n\ |
| 38367 | signed char a = p1;\n\ |
| 38368 | float b = p2;\n\ |
| 38369 | return a / b;\n\ |
| 38370 | }"; |
| 38371 | |
| 38372 | signed char (*proc)(signed char a, float b); |
| 38373 | cod_parse_context context = new_cod_parse_context(); |
| 38374 | int dumped = 0; |
| 38375 | |
| 38376 | cod_code gen_code; |
| 38377 | |
| 38378 | /* test for signed char / float */ |
| 38379 | if (verbose) printf("test for signed char / float"); |
| 38380 | |
| 38381 | cod_assoc_externs(context, externs); |
| 38382 | cod_parse_for_context(extern_string, context); |
| 38383 | |
| 38384 | cod_subroutine_declaration("signed char proc(signed char p1, float p2)", |
| 38385 | context); |
| 38386 | gen_code = cod_code_gen(code, context); |
| 38387 | proc = (signed char (*)(signed char, float))(long)gen_code->func; |
| 38388 | |
| 38389 | |
| 38390 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 38391 | signed char source1_c = src1c_vals[i]; |
| 38392 | for (j=0 ; j < sizeof(src2f_vals)/sizeof(src2f_vals[0]) ; j++) { |
| 38393 | float source2_f = src2f_vals[j]; |
| 38394 | double range = 0.000001 * (fabs((double)source1_c / (double)source2_f)); |
| 38395 | signed char expected_result; |
| 38396 | signed char result; |
| 38397 | |
| 38398 | if (source2_f == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip136;} |
| 38399 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 38400 | |
| 38401 | expected_result = (signed char) (source1_c / source2_f); |
| 38402 | |
| 38403 | result = proc(source1_c, source2_f); |
| 38404 | range += 1.0; |
| 38405 | if ((result > (expected_result + range)) || (result < (expected_result - range))) { |
| 38406 | printf("Failed signed char / float test, expected %d, got %d, for %d / %g\n", |
| 38407 | expected_result, result, source1_c, source2_f); |
| 38408 | if (dumped == 0) cod_dump(gen_code); |
| 38409 | failed++; |
| 38410 | dumped++; |
| 38411 | } |
| 38412 | skip136: ; |
| 38413 | } |
| 38414 | } |
| 38415 | if (verbose) printf(" done\n"); |
| 38416 | cod_free_parse_context(context); |
| 38417 | cod_code_free(gen_code); |
| 38418 | } |
| 38419 | if ((only_run_test == NULL((void*)0)) || |
| 38420 | (strcmp(only_run_test, "c/d") == 0)) { |
| 38421 | int i, j; |
| 38422 | static char code[] = "{\n\ |
| 38423 | signed char a = p1;\n\ |
| 38424 | double b = p2;\n\ |
| 38425 | return a / b;\n\ |
| 38426 | }"; |
| 38427 | |
| 38428 | signed char (*proc)(signed char a, double b); |
| 38429 | cod_parse_context context = new_cod_parse_context(); |
| 38430 | int dumped = 0; |
| 38431 | |
| 38432 | cod_code gen_code; |
| 38433 | |
| 38434 | /* test for signed char / double */ |
| 38435 | if (verbose) printf("test for signed char / double"); |
| 38436 | |
| 38437 | cod_assoc_externs(context, externs); |
| 38438 | cod_parse_for_context(extern_string, context); |
| 38439 | |
| 38440 | cod_subroutine_declaration("signed char proc(signed char p1, double p2)", |
| 38441 | context); |
| 38442 | gen_code = cod_code_gen(code, context); |
| 38443 | proc = (signed char (*)(signed char, double))(long)gen_code->func; |
| 38444 | |
| 38445 | |
| 38446 | for (i=0 ; i < sizeof(src1c_vals)/sizeof(src1c_vals[0]) ; i++) { |
| 38447 | signed char source1_c = src1c_vals[i]; |
| 38448 | for (j=0 ; j < sizeof(src2d_vals)/sizeof(src2d_vals[0]) ; j++) { |
| 38449 | double source2_d = src2d_vals[j]; |
| 38450 | |
| 38451 | signed char expected_result; |
| 38452 | signed char result; |
| 38453 | |
| 38454 | if (source2_d == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip137;} |
| 38455 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 38456 | |
| 38457 | expected_result = (signed char) (source1_c / source2_d); |
| 38458 | |
| 38459 | result = proc(source1_c, source2_d); |
| 38460 | if (expected_result != result) { |
| 38461 | printf("Failed signed char / double test, expected %d, got %d, for %d / %g\n", |
| 38462 | expected_result, result, source1_c, source2_d); |
| 38463 | if (dumped == 0) cod_dump(gen_code); |
| 38464 | failed++; |
| 38465 | dumped++; |
| 38466 | } |
| 38467 | skip137: ; |
| 38468 | } |
| 38469 | } |
| 38470 | if (verbose) printf(" done\n"); |
| 38471 | cod_free_parse_context(context); |
| 38472 | cod_code_free(gen_code); |
| 38473 | } |
| 38474 | } |
| 38475 | void div_uc_tests() |
| 38476 | { |
| 38477 | if ((only_run_test == NULL((void*)0)) || |
| 38478 | (strcmp(only_run_test, "uc/c") == 0)) { |
| 38479 | int i, j; |
| 38480 | static char code[] = "{\n\ |
| 38481 | unsigned char a = p1;\n\ |
| 38482 | signed char b = p2;\n\ |
| 38483 | return a / b;\n\ |
| 38484 | }"; |
| 38485 | |
| 38486 | unsigned char (*proc)(unsigned char a, signed char b); |
| 38487 | cod_parse_context context = new_cod_parse_context(); |
| 38488 | int dumped = 0; |
| 38489 | |
| 38490 | cod_code gen_code; |
| 38491 | |
| 38492 | /* test for unsigned char / signed char */ |
| 38493 | if (verbose) printf("test for unsigned char / signed char"); |
| 38494 | |
| 38495 | cod_assoc_externs(context, externs); |
| 38496 | cod_parse_for_context(extern_string, context); |
| 38497 | |
| 38498 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, signed char p2)", |
| 38499 | context); |
| 38500 | gen_code = cod_code_gen(code, context); |
| 38501 | proc = (unsigned char (*)(unsigned char, signed char))(long)gen_code->func; |
| 38502 | |
| 38503 | |
| 38504 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 38505 | unsigned char source1_uc = src1uc_vals[i]; |
| 38506 | for (j=0 ; j < sizeof(src2c_vals)/sizeof(src2c_vals[0]) ; j++) { |
| 38507 | signed char source2_c = src2c_vals[j]; |
| 38508 | |
| 38509 | unsigned int expect_int; |
| 38510 | unsigned char expected_result; |
| 38511 | unsigned char result; |
| 38512 | |
| 38513 | if (source2_c == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip138;} |
| 38514 | expect_int = (unsigned int) (source1_uc / source2_c); |
| 38515 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 38516 | |
| 38517 | expected_result = (unsigned char) expect_int; |
| 38518 | |
| 38519 | result = proc(source1_uc, source2_c); |
| 38520 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 38521 | if (expected_result != result) { |
| 38522 | printf("Failed unsigned char / signed char test, expected %u, got %u, for %u / %d\n", |
| 38523 | expected_result, result, source1_uc, source2_c); |
| 38524 | if (dumped == 0) cod_dump(gen_code); |
| 38525 | failed++; |
| 38526 | dumped++; |
| 38527 | } |
| 38528 | skip138: ; |
| 38529 | } |
| 38530 | } |
| 38531 | if (verbose) printf(" done\n"); |
| 38532 | cod_free_parse_context(context); |
| 38533 | cod_code_free(gen_code); |
| 38534 | } |
| 38535 | if ((only_run_test == NULL((void*)0)) || |
| 38536 | (strcmp(only_run_test, "uc/uc") == 0)) { |
| 38537 | int i, j; |
| 38538 | static char code[] = "{\n\ |
| 38539 | unsigned char a = p1;\n\ |
| 38540 | unsigned char b = p2;\n\ |
| 38541 | return a / b;\n\ |
| 38542 | }"; |
| 38543 | |
| 38544 | unsigned char (*proc)(unsigned char a, unsigned char b); |
| 38545 | cod_parse_context context = new_cod_parse_context(); |
| 38546 | int dumped = 0; |
| 38547 | |
| 38548 | cod_code gen_code; |
| 38549 | |
| 38550 | /* test for unsigned char / unsigned char */ |
| 38551 | if (verbose) printf("test for unsigned char / unsigned char"); |
| 38552 | |
| 38553 | cod_assoc_externs(context, externs); |
| 38554 | cod_parse_for_context(extern_string, context); |
| 38555 | |
| 38556 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, unsigned char p2)", |
| 38557 | context); |
| 38558 | gen_code = cod_code_gen(code, context); |
| 38559 | proc = (unsigned char (*)(unsigned char, unsigned char))(long)gen_code->func; |
| 38560 | |
| 38561 | |
| 38562 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 38563 | unsigned char source1_uc = src1uc_vals[i]; |
| 38564 | for (j=0 ; j < sizeof(src2uc_vals)/sizeof(src2uc_vals[0]) ; j++) { |
| 38565 | unsigned char source2_uc = src2uc_vals[j]; |
| 38566 | |
| 38567 | unsigned int expect_int; |
| 38568 | unsigned char expected_result; |
| 38569 | unsigned char result; |
| 38570 | |
| 38571 | if (source2_uc == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip139;} |
| 38572 | expect_int = (unsigned int) (source1_uc / source2_uc); |
| 38573 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 38574 | |
| 38575 | expected_result = (unsigned char) expect_int; |
| 38576 | |
| 38577 | result = proc(source1_uc, source2_uc); |
| 38578 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 38579 | if (expected_result != result) { |
| 38580 | printf("Failed unsigned char / unsigned char test, expected %u, got %u, for %u / %u\n", |
| 38581 | expected_result, result, source1_uc, source2_uc); |
| 38582 | if (dumped == 0) cod_dump(gen_code); |
| 38583 | failed++; |
| 38584 | dumped++; |
| 38585 | } |
| 38586 | skip139: ; |
| 38587 | } |
| 38588 | } |
| 38589 | if (verbose) printf(" done\n"); |
| 38590 | cod_free_parse_context(context); |
| 38591 | cod_code_free(gen_code); |
| 38592 | } |
| 38593 | if ((only_run_test == NULL((void*)0)) || |
| 38594 | (strcmp(only_run_test, "uc/s") == 0)) { |
| 38595 | int i, j; |
| 38596 | static char code[] = "{\n\ |
| 38597 | unsigned char a = p1;\n\ |
| 38598 | short b = p2;\n\ |
| 38599 | return a / b;\n\ |
| 38600 | }"; |
| 38601 | |
| 38602 | unsigned char (*proc)(unsigned char a, short b); |
| 38603 | cod_parse_context context = new_cod_parse_context(); |
| 38604 | int dumped = 0; |
| 38605 | |
| 38606 | cod_code gen_code; |
| 38607 | |
| 38608 | /* test for unsigned char / short */ |
| 38609 | if (verbose) printf("test for unsigned char / short"); |
| 38610 | |
| 38611 | cod_assoc_externs(context, externs); |
| 38612 | cod_parse_for_context(extern_string, context); |
| 38613 | |
| 38614 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, short p2)", |
| 38615 | context); |
| 38616 | gen_code = cod_code_gen(code, context); |
| 38617 | proc = (unsigned char (*)(unsigned char, short))(long)gen_code->func; |
| 38618 | |
| 38619 | |
| 38620 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 38621 | unsigned char source1_uc = src1uc_vals[i]; |
| 38622 | for (j=0 ; j < sizeof(src2s_vals)/sizeof(src2s_vals[0]) ; j++) { |
| 38623 | short source2_s = src2s_vals[j]; |
| 38624 | |
| 38625 | unsigned int expect_int; |
| 38626 | unsigned char expected_result; |
| 38627 | unsigned char result; |
| 38628 | |
| 38629 | if (source2_s == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip140;} |
| 38630 | expect_int = (unsigned int) (source1_uc / source2_s); |
| 38631 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 38632 | |
| 38633 | expected_result = (unsigned char) expect_int; |
| 38634 | |
| 38635 | result = proc(source1_uc, source2_s); |
| 38636 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 38637 | if (expected_result != result) { |
| 38638 | printf("Failed unsigned char / short test, expected %u, got %u, for %u / %d\n", |
| 38639 | expected_result, result, source1_uc, source2_s); |
| 38640 | if (dumped == 0) cod_dump(gen_code); |
| 38641 | failed++; |
| 38642 | dumped++; |
| 38643 | } |
| 38644 | skip140: ; |
| 38645 | } |
| 38646 | } |
| 38647 | if (verbose) printf(" done\n"); |
| 38648 | cod_free_parse_context(context); |
| 38649 | cod_code_free(gen_code); |
| 38650 | } |
| 38651 | if ((only_run_test == NULL((void*)0)) || |
| 38652 | (strcmp(only_run_test, "uc/us") == 0)) { |
| 38653 | int i, j; |
| 38654 | static char code[] = "{\n\ |
| 38655 | unsigned char a = p1;\n\ |
| 38656 | unsigned short b = p2;\n\ |
| 38657 | return a / b;\n\ |
| 38658 | }"; |
| 38659 | |
| 38660 | unsigned char (*proc)(unsigned char a, unsigned short b); |
| 38661 | cod_parse_context context = new_cod_parse_context(); |
| 38662 | int dumped = 0; |
| 38663 | |
| 38664 | cod_code gen_code; |
| 38665 | |
| 38666 | /* test for unsigned char / unsigned short */ |
| 38667 | if (verbose) printf("test for unsigned char / unsigned short"); |
| 38668 | |
| 38669 | cod_assoc_externs(context, externs); |
| 38670 | cod_parse_for_context(extern_string, context); |
| 38671 | |
| 38672 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, unsigned short p2)", |
| 38673 | context); |
| 38674 | gen_code = cod_code_gen(code, context); |
| 38675 | proc = (unsigned char (*)(unsigned char, unsigned short))(long)gen_code->func; |
| 38676 | |
| 38677 | |
| 38678 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 38679 | unsigned char source1_uc = src1uc_vals[i]; |
| 38680 | for (j=0 ; j < sizeof(src2us_vals)/sizeof(src2us_vals[0]) ; j++) { |
| 38681 | unsigned short source2_us = src2us_vals[j]; |
| 38682 | |
| 38683 | unsigned int expect_int; |
| 38684 | unsigned char expected_result; |
| 38685 | unsigned char result; |
| 38686 | |
| 38687 | if (source2_us == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip141;} |
| 38688 | expect_int = (unsigned int) (source1_uc / source2_us); |
| 38689 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 38690 | |
| 38691 | expected_result = (unsigned char) expect_int; |
| 38692 | |
| 38693 | result = proc(source1_uc, source2_us); |
| 38694 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 38695 | if (expected_result != result) { |
| 38696 | printf("Failed unsigned char / unsigned short test, expected %u, got %u, for %u / %u\n", |
| 38697 | expected_result, result, source1_uc, source2_us); |
| 38698 | if (dumped == 0) cod_dump(gen_code); |
| 38699 | failed++; |
| 38700 | dumped++; |
| 38701 | } |
| 38702 | skip141: ; |
| 38703 | } |
| 38704 | } |
| 38705 | if (verbose) printf(" done\n"); |
| 38706 | cod_free_parse_context(context); |
| 38707 | cod_code_free(gen_code); |
| 38708 | } |
| 38709 | if ((only_run_test == NULL((void*)0)) || |
| 38710 | (strcmp(only_run_test, "uc/i") == 0)) { |
| 38711 | int i, j; |
| 38712 | static char code[] = "{\n\ |
| 38713 | unsigned char a = p1;\n\ |
| 38714 | int b = p2;\n\ |
| 38715 | return a / b;\n\ |
| 38716 | }"; |
| 38717 | |
| 38718 | unsigned char (*proc)(unsigned char a, int b); |
| 38719 | cod_parse_context context = new_cod_parse_context(); |
| 38720 | int dumped = 0; |
| 38721 | |
| 38722 | cod_code gen_code; |
| 38723 | |
| 38724 | /* test for unsigned char / int */ |
| 38725 | if (verbose) printf("test for unsigned char / int"); |
| 38726 | |
| 38727 | cod_assoc_externs(context, externs); |
| 38728 | cod_parse_for_context(extern_string, context); |
| 38729 | |
| 38730 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, int p2)", |
| 38731 | context); |
| 38732 | gen_code = cod_code_gen(code, context); |
| 38733 | proc = (unsigned char (*)(unsigned char, int))(long)gen_code->func; |
| 38734 | |
| 38735 | |
| 38736 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 38737 | unsigned char source1_uc = src1uc_vals[i]; |
| 38738 | for (j=0 ; j < sizeof(src2i_vals)/sizeof(src2i_vals[0]) ; j++) { |
| 38739 | int source2_i = src2i_vals[j]; |
| 38740 | |
| 38741 | unsigned int expect_int; |
| 38742 | unsigned char expected_result; |
| 38743 | unsigned char result; |
| 38744 | |
| 38745 | if (source2_i == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip142;} |
| 38746 | expect_int = (unsigned int) (source1_uc / source2_i); |
| 38747 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 38748 | |
| 38749 | expected_result = (unsigned char) expect_int; |
| 38750 | |
| 38751 | result = proc(source1_uc, source2_i); |
| 38752 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 38753 | if (expected_result != result) { |
| 38754 | printf("Failed unsigned char / int test, expected %u, got %u, for %u / %d\n", |
| 38755 | expected_result, result, source1_uc, source2_i); |
| 38756 | if (dumped == 0) cod_dump(gen_code); |
| 38757 | failed++; |
| 38758 | dumped++; |
| 38759 | } |
| 38760 | skip142: ; |
| 38761 | } |
| 38762 | } |
| 38763 | if (verbose) printf(" done\n"); |
| 38764 | cod_free_parse_context(context); |
| 38765 | cod_code_free(gen_code); |
| 38766 | } |
| 38767 | if ((only_run_test == NULL((void*)0)) || |
| 38768 | (strcmp(only_run_test, "uc/u") == 0)) { |
| 38769 | int i, j; |
| 38770 | static char code[] = "{\n\ |
| 38771 | unsigned char a = p1;\n\ |
| 38772 | unsigned int b = p2;\n\ |
| 38773 | return a / b;\n\ |
| 38774 | }"; |
| 38775 | |
| 38776 | unsigned char (*proc)(unsigned char a, unsigned int b); |
| 38777 | cod_parse_context context = new_cod_parse_context(); |
| 38778 | int dumped = 0; |
| 38779 | |
| 38780 | cod_code gen_code; |
| 38781 | |
| 38782 | /* test for unsigned char / unsigned int */ |
| 38783 | if (verbose) printf("test for unsigned char / unsigned int"); |
| 38784 | |
| 38785 | cod_assoc_externs(context, externs); |
| 38786 | cod_parse_for_context(extern_string, context); |
| 38787 | |
| 38788 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, unsigned int p2)", |
| 38789 | context); |
| 38790 | gen_code = cod_code_gen(code, context); |
| 38791 | proc = (unsigned char (*)(unsigned char, unsigned int))(long)gen_code->func; |
| 38792 | |
| 38793 | |
| 38794 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 38795 | unsigned char source1_uc = src1uc_vals[i]; |
| 38796 | for (j=0 ; j < sizeof(src2u_vals)/sizeof(src2u_vals[0]) ; j++) { |
| 38797 | unsigned int source2_u = src2u_vals[j]; |
| 38798 | |
| 38799 | unsigned int expect_int; |
| 38800 | unsigned char expected_result; |
| 38801 | unsigned char result; |
| 38802 | |
| 38803 | if (source2_u == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip143;} |
| 38804 | expect_int = (unsigned int) (source1_uc / source2_u); |
| 38805 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 38806 | |
| 38807 | expected_result = (unsigned char) expect_int; |
| 38808 | |
| 38809 | result = proc(source1_uc, source2_u); |
| 38810 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 38811 | if (expected_result != result) { |
| 38812 | printf("Failed unsigned char / unsigned int test, expected %u, got %u, for %u / %u\n", |
| 38813 | expected_result, result, source1_uc, source2_u); |
| 38814 | if (dumped == 0) cod_dump(gen_code); |
| 38815 | failed++; |
| 38816 | dumped++; |
| 38817 | } |
| 38818 | skip143: ; |
| 38819 | } |
| 38820 | } |
| 38821 | if (verbose) printf(" done\n"); |
| 38822 | cod_free_parse_context(context); |
| 38823 | cod_code_free(gen_code); |
| 38824 | } |
| 38825 | if ((only_run_test == NULL((void*)0)) || |
| 38826 | (strcmp(only_run_test, "uc/ul") == 0)) { |
| 38827 | int i, j; |
| 38828 | static char code[] = "{\n\ |
| 38829 | unsigned char a = p1;\n\ |
| 38830 | unsigned long b = p2;\n\ |
| 38831 | return a / b;\n\ |
| 38832 | }"; |
| 38833 | |
| 38834 | unsigned char (*proc)(unsigned char a, unsigned long b); |
| 38835 | cod_parse_context context = new_cod_parse_context(); |
| 38836 | int dumped = 0; |
| 38837 | |
| 38838 | cod_code gen_code; |
| 38839 | |
| 38840 | /* test for unsigned char / unsigned long */ |
| 38841 | if (verbose) printf("test for unsigned char / unsigned long"); |
| 38842 | |
| 38843 | cod_assoc_externs(context, externs); |
| 38844 | cod_parse_for_context(extern_string, context); |
| 38845 | |
| 38846 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, unsigned long p2)", |
| 38847 | context); |
| 38848 | gen_code = cod_code_gen(code, context); |
| 38849 | proc = (unsigned char (*)(unsigned char, unsigned long))(long)gen_code->func; |
| 38850 | |
| 38851 | |
| 38852 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 38853 | unsigned char source1_uc = src1uc_vals[i]; |
| 38854 | for (j=0 ; j < sizeof(src2ul_vals)/sizeof(src2ul_vals[0]) ; j++) { |
| 38855 | unsigned long source2_ul = src2ul_vals[j]; |
| 38856 | |
| 38857 | unsigned int expect_int; |
| 38858 | unsigned char expected_result; |
| 38859 | unsigned char result; |
| 38860 | |
| 38861 | if (source2_ul == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip144;} |
| 38862 | expect_int = (unsigned int) (source1_uc / source2_ul); |
| 38863 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 38864 | |
| 38865 | expected_result = (unsigned char) expect_int; |
| 38866 | |
| 38867 | result = proc(source1_uc, source2_ul); |
| 38868 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 38869 | if (expected_result != result) { |
| 38870 | printf("Failed unsigned char / unsigned long test, expected %u, got %u, for %u / %lu\n", |
| 38871 | expected_result, result, source1_uc, source2_ul); |
| 38872 | if (dumped == 0) cod_dump(gen_code); |
| 38873 | failed++; |
| 38874 | dumped++; |
| 38875 | } |
| 38876 | skip144: ; |
| 38877 | } |
| 38878 | } |
| 38879 | if (verbose) printf(" done\n"); |
| 38880 | cod_free_parse_context(context); |
| 38881 | cod_code_free(gen_code); |
| 38882 | } |
| 38883 | if ((only_run_test == NULL((void*)0)) || |
| 38884 | (strcmp(only_run_test, "uc/l") == 0)) { |
| 38885 | int i, j; |
| 38886 | static char code[] = "{\n\ |
| 38887 | unsigned char a = p1;\n\ |
| 38888 | long b = p2;\n\ |
| 38889 | return a / b;\n\ |
| 38890 | }"; |
| 38891 | |
| 38892 | unsigned char (*proc)(unsigned char a, long b); |
| 38893 | cod_parse_context context = new_cod_parse_context(); |
| 38894 | int dumped = 0; |
| 38895 | |
| 38896 | cod_code gen_code; |
| 38897 | |
| 38898 | /* test for unsigned char / long */ |
| 38899 | if (verbose) printf("test for unsigned char / long"); |
| 38900 | |
| 38901 | cod_assoc_externs(context, externs); |
| 38902 | cod_parse_for_context(extern_string, context); |
| 38903 | |
| 38904 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, long p2)", |
| 38905 | context); |
| 38906 | gen_code = cod_code_gen(code, context); |
| 38907 | proc = (unsigned char (*)(unsigned char, long))(long)gen_code->func; |
| 38908 | |
| 38909 | |
| 38910 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 38911 | unsigned char source1_uc = src1uc_vals[i]; |
| 38912 | for (j=0 ; j < sizeof(src2l_vals)/sizeof(src2l_vals[0]) ; j++) { |
| 38913 | long source2_l = src2l_vals[j]; |
| 38914 | |
| 38915 | unsigned int expect_int; |
| 38916 | unsigned char expected_result; |
| 38917 | unsigned char result; |
| 38918 | |
| 38919 | if (source2_l == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip145;} |
| 38920 | expect_int = (unsigned int) (source1_uc / source2_l); |
| 38921 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 38922 | |
| 38923 | expected_result = (unsigned char) expect_int; |
| 38924 | |
| 38925 | result = proc(source1_uc, source2_l); |
| 38926 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 38927 | if (expected_result != result) { |
| 38928 | printf("Failed unsigned char / long test, expected %u, got %u, for %u / %ld\n", |
| 38929 | expected_result, result, source1_uc, source2_l); |
| 38930 | if (dumped == 0) cod_dump(gen_code); |
| 38931 | failed++; |
| 38932 | dumped++; |
| 38933 | } |
| 38934 | skip145: ; |
| 38935 | } |
| 38936 | } |
| 38937 | if (verbose) printf(" done\n"); |
| 38938 | cod_free_parse_context(context); |
| 38939 | cod_code_free(gen_code); |
| 38940 | } |
| 38941 | if ((only_run_test == NULL((void*)0)) || |
| 38942 | (strcmp(only_run_test, "uc/f") == 0)) { |
| 38943 | int i, j; |
| 38944 | static char code[] = "{\n\ |
| 38945 | unsigned char a = p1;\n\ |
| 38946 | float b = p2;\n\ |
| 38947 | return a / b;\n\ |
| 38948 | }"; |
| 38949 | |
| 38950 | unsigned char (*proc)(unsigned char a, float b); |
| 38951 | cod_parse_context context = new_cod_parse_context(); |
| 38952 | int dumped = 0; |
| 38953 | |
| 38954 | cod_code gen_code; |
| 38955 | |
| 38956 | /* test for unsigned char / float */ |
| 38957 | if (verbose) printf("test for unsigned char / float"); |
| 38958 | |
| 38959 | cod_assoc_externs(context, externs); |
| 38960 | cod_parse_for_context(extern_string, context); |
| 38961 | |
| 38962 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, float p2)", |
| 38963 | context); |
| 38964 | gen_code = cod_code_gen(code, context); |
| 38965 | proc = (unsigned char (*)(unsigned char, float))(long)gen_code->func; |
| 38966 | |
| 38967 | |
| 38968 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 38969 | unsigned char source1_uc = src1uc_vals[i]; |
| 38970 | for (j=0 ; j < sizeof(src2f_vals)/sizeof(src2f_vals[0]) ; j++) { |
| 38971 | float source2_f = src2f_vals[j]; |
| 38972 | double range = 0.000001 * (fabs((double)source1_uc / (double)source2_f)); |
| 38973 | unsigned int expect_int; |
| 38974 | unsigned char expected_result; |
| 38975 | unsigned char result; |
| 38976 | |
| 38977 | if (source2_f == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip146;} |
| 38978 | expect_int = (unsigned int) (source1_uc / source2_f); |
| 38979 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 38980 | |
| 38981 | expected_result = (unsigned char) expect_int; |
| 38982 | |
| 38983 | result = proc(source1_uc, source2_f); |
| 38984 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 38985 | range += 1.0; |
| 38986 | if ((result > (expected_result + range)) || (result < (expected_result - range))) { |
| 38987 | printf("Failed unsigned char / float test, expected %u, got %u, for %u / %g\n", |
| 38988 | expected_result, result, source1_uc, source2_f); |
| 38989 | if (dumped == 0) cod_dump(gen_code); |
| 38990 | failed++; |
| 38991 | dumped++; |
| 38992 | } |
| 38993 | skip146: ; |
| 38994 | } |
| 38995 | } |
| 38996 | if (verbose) printf(" done\n"); |
| 38997 | cod_free_parse_context(context); |
| 38998 | cod_code_free(gen_code); |
| 38999 | } |
| 39000 | if ((only_run_test == NULL((void*)0)) || |
| 39001 | (strcmp(only_run_test, "uc/d") == 0)) { |
| 39002 | int i, j; |
| 39003 | static char code[] = "{\n\ |
| 39004 | unsigned char a = p1;\n\ |
| 39005 | double b = p2;\n\ |
| 39006 | return a / b;\n\ |
| 39007 | }"; |
| 39008 | |
| 39009 | unsigned char (*proc)(unsigned char a, double b); |
| 39010 | cod_parse_context context = new_cod_parse_context(); |
| 39011 | int dumped = 0; |
| 39012 | |
| 39013 | cod_code gen_code; |
| 39014 | |
| 39015 | /* test for unsigned char / double */ |
| 39016 | if (verbose) printf("test for unsigned char / double"); |
| 39017 | |
| 39018 | cod_assoc_externs(context, externs); |
| 39019 | cod_parse_for_context(extern_string, context); |
| 39020 | |
| 39021 | cod_subroutine_declaration("unsigned char proc(unsigned char p1, double p2)", |
| 39022 | context); |
| 39023 | gen_code = cod_code_gen(code, context); |
| 39024 | proc = (unsigned char (*)(unsigned char, double))(long)gen_code->func; |
| 39025 | |
| 39026 | |
| 39027 | for (i=0 ; i < sizeof(src1uc_vals)/sizeof(src1uc_vals[0]) ; i++) { |
| 39028 | unsigned char source1_uc = src1uc_vals[i]; |
| 39029 | for (j=0 ; j < sizeof(src2d_vals)/sizeof(src2d_vals[0]) ; j++) { |
| 39030 | double source2_d = src2d_vals[j]; |
| 39031 | |
| 39032 | unsigned int expect_int; |
| 39033 | unsigned char expected_result; |
| 39034 | unsigned char result; |
| 39035 | |
| 39036 | if (source2_d == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip147;} |
| 39037 | expect_int = (unsigned int) (source1_uc / source2_d); |
| 39038 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 39039 | |
| 39040 | expected_result = (unsigned char) expect_int; |
| 39041 | |
| 39042 | result = proc(source1_uc, source2_d); |
| 39043 | if ((expected_result == 0) || (expected_result == (unsigned char) 0xff) || (expected_result == (unsigned char) 0x80)) continue; |
| 39044 | if (expected_result != result) { |
| 39045 | printf("Failed unsigned char / double test, expected %u, got %u, for %u / %g\n", |
| 39046 | expected_result, result, source1_uc, source2_d); |
| 39047 | if (dumped == 0) cod_dump(gen_code); |
| 39048 | failed++; |
| 39049 | dumped++; |
| 39050 | } |
| 39051 | skip147: ; |
| 39052 | } |
| 39053 | } |
| 39054 | if (verbose) printf(" done\n"); |
| 39055 | cod_free_parse_context(context); |
| 39056 | cod_code_free(gen_code); |
| 39057 | } |
| 39058 | } |
| 39059 | void div_s_tests() |
| 39060 | { |
| 39061 | if ((only_run_test == NULL((void*)0)) || |
| 39062 | (strcmp(only_run_test, "s/c") == 0)) { |
| 39063 | int i, j; |
| 39064 | static char code[] = "{\n\ |
| 39065 | short a = p1;\n\ |
| 39066 | signed char b = p2;\n\ |
| 39067 | return a / b;\n\ |
| 39068 | }"; |
| 39069 | |
| 39070 | short (*proc)(short a, signed char b); |
| 39071 | cod_parse_context context = new_cod_parse_context(); |
| 39072 | int dumped = 0; |
| 39073 | |
| 39074 | cod_code gen_code; |
| 39075 | |
| 39076 | /* test for short / signed char */ |
| 39077 | if (verbose) printf("test for short / signed char"); |
| 39078 | |
| 39079 | cod_assoc_externs(context, externs); |
| 39080 | cod_parse_for_context(extern_string, context); |
| 39081 | |
| 39082 | cod_subroutine_declaration("short proc(short p1, signed char p2)", |
| 39083 | context); |
| 39084 | gen_code = cod_code_gen(code, context); |
| 39085 | proc = (short (*)(short, signed char))(long)gen_code->func; |
| 39086 | |
| 39087 | |
| 39088 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 39089 | short source1_s = src1s_vals[i]; |
| 39090 | for (j=0 ; j < sizeof(src2c_vals)/sizeof(src2c_vals[0]) ; j++) { |
| 39091 | signed char source2_c = src2c_vals[j]; |
| 39092 | |
| 39093 | short expected_result; |
| 39094 | short result; |
| 39095 | |
| 39096 | if (source2_c == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip148;} |
| 39097 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 39098 | |
| 39099 | expected_result = (short) (source1_s / source2_c); |
| 39100 | |
| 39101 | result = proc(source1_s, source2_c); |
| 39102 | if (expected_result != result) { |
| 39103 | printf("Failed short / signed char test, expected %d, got %d, for %d / %d\n", |
| 39104 | expected_result, result, source1_s, source2_c); |
| 39105 | if (dumped == 0) cod_dump(gen_code); |
| 39106 | failed++; |
| 39107 | dumped++; |
| 39108 | } |
| 39109 | skip148: ; |
| 39110 | } |
| 39111 | } |
| 39112 | if (verbose) printf(" done\n"); |
| 39113 | cod_free_parse_context(context); |
| 39114 | cod_code_free(gen_code); |
| 39115 | } |
| 39116 | if ((only_run_test == NULL((void*)0)) || |
| 39117 | (strcmp(only_run_test, "s/uc") == 0)) { |
| 39118 | int i, j; |
| 39119 | static char code[] = "{\n\ |
| 39120 | short a = p1;\n\ |
| 39121 | unsigned char b = p2;\n\ |
| 39122 | return a / b;\n\ |
| 39123 | }"; |
| 39124 | |
| 39125 | short (*proc)(short a, unsigned char b); |
| 39126 | cod_parse_context context = new_cod_parse_context(); |
| 39127 | int dumped = 0; |
| 39128 | |
| 39129 | cod_code gen_code; |
| 39130 | |
| 39131 | /* test for short / unsigned char */ |
| 39132 | if (verbose) printf("test for short / unsigned char"); |
| 39133 | |
| 39134 | cod_assoc_externs(context, externs); |
| 39135 | cod_parse_for_context(extern_string, context); |
| 39136 | |
| 39137 | cod_subroutine_declaration("short proc(short p1, unsigned char p2)", |
| 39138 | context); |
| 39139 | gen_code = cod_code_gen(code, context); |
| 39140 | proc = (short (*)(short, unsigned char))(long)gen_code->func; |
| 39141 | |
| 39142 | |
| 39143 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 39144 | short source1_s = src1s_vals[i]; |
| 39145 | for (j=0 ; j < sizeof(src2uc_vals)/sizeof(src2uc_vals[0]) ; j++) { |
| 39146 | unsigned char source2_uc = src2uc_vals[j]; |
| 39147 | |
| 39148 | short expected_result; |
| 39149 | short result; |
| 39150 | |
| 39151 | if (source2_uc == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip149;} |
| 39152 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 39153 | |
| 39154 | expected_result = (short) (source1_s / source2_uc); |
| 39155 | |
| 39156 | result = proc(source1_s, source2_uc); |
| 39157 | if (expected_result != result) { |
| 39158 | printf("Failed short / unsigned char test, expected %d, got %d, for %d / %u\n", |
| 39159 | expected_result, result, source1_s, source2_uc); |
| 39160 | if (dumped == 0) cod_dump(gen_code); |
| 39161 | failed++; |
| 39162 | dumped++; |
| 39163 | } |
| 39164 | skip149: ; |
| 39165 | } |
| 39166 | } |
| 39167 | if (verbose) printf(" done\n"); |
| 39168 | cod_free_parse_context(context); |
| 39169 | cod_code_free(gen_code); |
| 39170 | } |
| 39171 | if ((only_run_test == NULL((void*)0)) || |
| 39172 | (strcmp(only_run_test, "s/s") == 0)) { |
| 39173 | int i, j; |
| 39174 | static char code[] = "{\n\ |
| 39175 | short a = p1;\n\ |
| 39176 | short b = p2;\n\ |
| 39177 | return a / b;\n\ |
| 39178 | }"; |
| 39179 | |
| 39180 | short (*proc)(short a, short b); |
| 39181 | cod_parse_context context = new_cod_parse_context(); |
| 39182 | int dumped = 0; |
| 39183 | |
| 39184 | cod_code gen_code; |
| 39185 | |
| 39186 | /* test for short / short */ |
| 39187 | if (verbose) printf("test for short / short"); |
| 39188 | |
| 39189 | cod_assoc_externs(context, externs); |
| 39190 | cod_parse_for_context(extern_string, context); |
| 39191 | |
| 39192 | cod_subroutine_declaration("short proc(short p1, short p2)", |
| 39193 | context); |
| 39194 | gen_code = cod_code_gen(code, context); |
| 39195 | proc = (short (*)(short, short))(long)gen_code->func; |
| 39196 | |
| 39197 | |
| 39198 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 39199 | short source1_s = src1s_vals[i]; |
| 39200 | for (j=0 ; j < sizeof(src2s_vals)/sizeof(src2s_vals[0]) ; j++) { |
| 39201 | short source2_s = src2s_vals[j]; |
| 39202 | |
| 39203 | short expected_result; |
| 39204 | short result; |
| 39205 | |
| 39206 | if (source2_s == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip150;} |
| 39207 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 39208 | |
| 39209 | expected_result = (short) (source1_s / source2_s); |
| 39210 | |
| 39211 | result = proc(source1_s, source2_s); |
| 39212 | if (expected_result != result) { |
| 39213 | printf("Failed short / short test, expected %d, got %d, for %d / %d\n", |
| 39214 | expected_result, result, source1_s, source2_s); |
| 39215 | if (dumped == 0) cod_dump(gen_code); |
| 39216 | failed++; |
| 39217 | dumped++; |
| 39218 | } |
| 39219 | skip150: ; |
| 39220 | } |
| 39221 | } |
| 39222 | if (verbose) printf(" done\n"); |
| 39223 | cod_free_parse_context(context); |
| 39224 | cod_code_free(gen_code); |
| 39225 | } |
| 39226 | if ((only_run_test == NULL((void*)0)) || |
| 39227 | (strcmp(only_run_test, "s/us") == 0)) { |
| 39228 | int i, j; |
| 39229 | static char code[] = "{\n\ |
| 39230 | short a = p1;\n\ |
| 39231 | unsigned short b = p2;\n\ |
| 39232 | return a / b;\n\ |
| 39233 | }"; |
| 39234 | |
| 39235 | short (*proc)(short a, unsigned short b); |
| 39236 | cod_parse_context context = new_cod_parse_context(); |
| 39237 | int dumped = 0; |
| 39238 | |
| 39239 | cod_code gen_code; |
| 39240 | |
| 39241 | /* test for short / unsigned short */ |
| 39242 | if (verbose) printf("test for short / unsigned short"); |
| 39243 | |
| 39244 | cod_assoc_externs(context, externs); |
| 39245 | cod_parse_for_context(extern_string, context); |
| 39246 | |
| 39247 | cod_subroutine_declaration("short proc(short p1, unsigned short p2)", |
| 39248 | context); |
| 39249 | gen_code = cod_code_gen(code, context); |
| 39250 | proc = (short (*)(short, unsigned short))(long)gen_code->func; |
| 39251 | |
| 39252 | |
| 39253 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 39254 | short source1_s = src1s_vals[i]; |
| 39255 | for (j=0 ; j < sizeof(src2us_vals)/sizeof(src2us_vals[0]) ; j++) { |
| 39256 | unsigned short source2_us = src2us_vals[j]; |
| 39257 | |
| 39258 | short expected_result; |
| 39259 | short result; |
| 39260 | |
| 39261 | if (source2_us == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip151;} |
| 39262 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 39263 | |
| 39264 | expected_result = (short) (source1_s / source2_us); |
| 39265 | |
| 39266 | result = proc(source1_s, source2_us); |
| 39267 | if (expected_result != result) { |
| 39268 | printf("Failed short / unsigned short test, expected %d, got %d, for %d / %u\n", |
| 39269 | expected_result, result, source1_s, source2_us); |
| 39270 | if (dumped == 0) cod_dump(gen_code); |
| 39271 | failed++; |
| 39272 | dumped++; |
| 39273 | } |
| 39274 | skip151: ; |
| 39275 | } |
| 39276 | } |
| 39277 | if (verbose) printf(" done\n"); |
| 39278 | cod_free_parse_context(context); |
| 39279 | cod_code_free(gen_code); |
| 39280 | } |
| 39281 | if ((only_run_test == NULL((void*)0)) || |
| 39282 | (strcmp(only_run_test, "s/i") == 0)) { |
| 39283 | int i, j; |
| 39284 | static char code[] = "{\n\ |
| 39285 | short a = p1;\n\ |
| 39286 | int b = p2;\n\ |
| 39287 | return a / b;\n\ |
| 39288 | }"; |
| 39289 | |
| 39290 | short (*proc)(short a, int b); |
| 39291 | cod_parse_context context = new_cod_parse_context(); |
| 39292 | int dumped = 0; |
| 39293 | |
| 39294 | cod_code gen_code; |
| 39295 | |
| 39296 | /* test for short / int */ |
| 39297 | if (verbose) printf("test for short / int"); |
| 39298 | |
| 39299 | cod_assoc_externs(context, externs); |
| 39300 | cod_parse_for_context(extern_string, context); |
| 39301 | |
| 39302 | cod_subroutine_declaration("short proc(short p1, int p2)", |
| 39303 | context); |
| 39304 | gen_code = cod_code_gen(code, context); |
| 39305 | proc = (short (*)(short, int))(long)gen_code->func; |
| 39306 | |
| 39307 | |
| 39308 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 39309 | short source1_s = src1s_vals[i]; |
| 39310 | for (j=0 ; j < sizeof(src2i_vals)/sizeof(src2i_vals[0]) ; j++) { |
| 39311 | int source2_i = src2i_vals[j]; |
| 39312 | |
| 39313 | short expected_result; |
| 39314 | short result; |
| 39315 | |
| 39316 | if (source2_i == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip152;} |
| 39317 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 39318 | |
| 39319 | expected_result = (short) (source1_s / source2_i); |
| 39320 | |
| 39321 | result = proc(source1_s, source2_i); |
| 39322 | if (expected_result != result) { |
| 39323 | printf("Failed short / int test, expected %d, got %d, for %d / %d\n", |
| 39324 | expected_result, result, source1_s, source2_i); |
| 39325 | if (dumped == 0) cod_dump(gen_code); |
| 39326 | failed++; |
| 39327 | dumped++; |
| 39328 | } |
| 39329 | skip152: ; |
| 39330 | } |
| 39331 | } |
| 39332 | if (verbose) printf(" done\n"); |
| 39333 | cod_free_parse_context(context); |
| 39334 | cod_code_free(gen_code); |
| 39335 | } |
| 39336 | if ((only_run_test == NULL((void*)0)) || |
| 39337 | (strcmp(only_run_test, "s/u") == 0)) { |
| 39338 | int i, j; |
| 39339 | static char code[] = "{\n\ |
| 39340 | short a = p1;\n\ |
| 39341 | unsigned int b = p2;\n\ |
| 39342 | return a / b;\n\ |
| 39343 | }"; |
| 39344 | |
| 39345 | short (*proc)(short a, unsigned int b); |
| 39346 | cod_parse_context context = new_cod_parse_context(); |
| 39347 | int dumped = 0; |
| 39348 | |
| 39349 | cod_code gen_code; |
| 39350 | |
| 39351 | /* test for short / unsigned int */ |
| 39352 | if (verbose) printf("test for short / unsigned int"); |
| 39353 | |
| 39354 | cod_assoc_externs(context, externs); |
| 39355 | cod_parse_for_context(extern_string, context); |
| 39356 | |
| 39357 | cod_subroutine_declaration("short proc(short p1, unsigned int p2)", |
| 39358 | context); |
| 39359 | gen_code = cod_code_gen(code, context); |
| 39360 | proc = (short (*)(short, unsigned int))(long)gen_code->func; |
| 39361 | |
| 39362 | |
| 39363 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 39364 | short source1_s = src1s_vals[i]; |
| 39365 | for (j=0 ; j < sizeof(src2u_vals)/sizeof(src2u_vals[0]) ; j++) { |
| 39366 | unsigned int source2_u = src2u_vals[j]; |
| 39367 | |
| 39368 | short expected_result; |
| 39369 | short result; |
| 39370 | |
| 39371 | if (source2_u == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip153;} |
| 39372 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 39373 | |
| 39374 | expected_result = (short) (source1_s / source2_u); |
| 39375 | |
| 39376 | result = proc(source1_s, source2_u); |
| 39377 | if (expected_result != result) { |
| 39378 | printf("Failed short / unsigned int test, expected %d, got %d, for %d / %u\n", |
| 39379 | expected_result, result, source1_s, source2_u); |
| 39380 | if (dumped == 0) cod_dump(gen_code); |
| 39381 | failed++; |
| 39382 | dumped++; |
| 39383 | } |
| 39384 | skip153: ; |
| 39385 | } |
| 39386 | } |
| 39387 | if (verbose) printf(" done\n"); |
| 39388 | cod_free_parse_context(context); |
| 39389 | cod_code_free(gen_code); |
| 39390 | } |
| 39391 | if ((only_run_test == NULL((void*)0)) || |
| 39392 | (strcmp(only_run_test, "s/ul") == 0)) { |
| 39393 | int i, j; |
| 39394 | static char code[] = "{\n\ |
| 39395 | short a = p1;\n\ |
| 39396 | unsigned long b = p2;\n\ |
| 39397 | return a / b;\n\ |
| 39398 | }"; |
| 39399 | |
| 39400 | short (*proc)(short a, unsigned long b); |
| 39401 | cod_parse_context context = new_cod_parse_context(); |
| 39402 | int dumped = 0; |
| 39403 | |
| 39404 | cod_code gen_code; |
| 39405 | |
| 39406 | /* test for short / unsigned long */ |
| 39407 | if (verbose) printf("test for short / unsigned long"); |
| 39408 | |
| 39409 | cod_assoc_externs(context, externs); |
| 39410 | cod_parse_for_context(extern_string, context); |
| 39411 | |
| 39412 | cod_subroutine_declaration("short proc(short p1, unsigned long p2)", |
| 39413 | context); |
| 39414 | gen_code = cod_code_gen(code, context); |
| 39415 | proc = (short (*)(short, unsigned long))(long)gen_code->func; |
| 39416 | |
| 39417 | |
| 39418 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 39419 | short source1_s = src1s_vals[i]; |
| 39420 | for (j=0 ; j < sizeof(src2ul_vals)/sizeof(src2ul_vals[0]) ; j++) { |
| 39421 | unsigned long source2_ul = src2ul_vals[j]; |
| 39422 | |
| 39423 | short expected_result; |
| 39424 | short result; |
| 39425 | |
| 39426 | if (source2_ul == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip154;} |
| 39427 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 39428 | |
| 39429 | expected_result = (short) (source1_s / source2_ul); |
| 39430 | |
| 39431 | result = proc(source1_s, source2_ul); |
| 39432 | if (expected_result != result) { |
| 39433 | printf("Failed short / unsigned long test, expected %d, got %d, for %d / %lu\n", |
| 39434 | expected_result, result, source1_s, source2_ul); |
| 39435 | if (dumped == 0) cod_dump(gen_code); |
| 39436 | failed++; |
| 39437 | dumped++; |
| 39438 | } |
| 39439 | skip154: ; |
| 39440 | } |
| 39441 | } |
| 39442 | if (verbose) printf(" done\n"); |
| 39443 | cod_free_parse_context(context); |
| 39444 | cod_code_free(gen_code); |
| 39445 | } |
| 39446 | if ((only_run_test == NULL((void*)0)) || |
| 39447 | (strcmp(only_run_test, "s/l") == 0)) { |
| 39448 | int i, j; |
| 39449 | static char code[] = "{\n\ |
| 39450 | short a = p1;\n\ |
| 39451 | long b = p2;\n\ |
| 39452 | return a / b;\n\ |
| 39453 | }"; |
| 39454 | |
| 39455 | short (*proc)(short a, long b); |
| 39456 | cod_parse_context context = new_cod_parse_context(); |
| 39457 | int dumped = 0; |
| 39458 | |
| 39459 | cod_code gen_code; |
| 39460 | |
| 39461 | /* test for short / long */ |
| 39462 | if (verbose) printf("test for short / long"); |
| 39463 | |
| 39464 | cod_assoc_externs(context, externs); |
| 39465 | cod_parse_for_context(extern_string, context); |
| 39466 | |
| 39467 | cod_subroutine_declaration("short proc(short p1, long p2)", |
| 39468 | context); |
| 39469 | gen_code = cod_code_gen(code, context); |
| 39470 | proc = (short (*)(short, long))(long)gen_code->func; |
| 39471 | |
| 39472 | |
| 39473 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 39474 | short source1_s = src1s_vals[i]; |
| 39475 | for (j=0 ; j < sizeof(src2l_vals)/sizeof(src2l_vals[0]) ; j++) { |
| 39476 | long source2_l = src2l_vals[j]; |
| 39477 | |
| 39478 | short expected_result; |
| 39479 | short result; |
| 39480 | |
| 39481 | if (source2_l == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip155;} |
| 39482 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 39483 | |
| 39484 | expected_result = (short) (source1_s / source2_l); |
| 39485 | |
| 39486 | result = proc(source1_s, source2_l); |
| 39487 | if (expected_result != result) { |
| 39488 | printf("Failed short / long test, expected %d, got %d, for %d / %ld\n", |
| 39489 | expected_result, result, source1_s, source2_l); |
| 39490 | if (dumped == 0) cod_dump(gen_code); |
| 39491 | failed++; |
| 39492 | dumped++; |
| 39493 | } |
| 39494 | skip155: ; |
| 39495 | } |
| 39496 | } |
| 39497 | if (verbose) printf(" done\n"); |
| 39498 | cod_free_parse_context(context); |
| 39499 | cod_code_free(gen_code); |
| 39500 | } |
| 39501 | if ((only_run_test == NULL((void*)0)) || |
| 39502 | (strcmp(only_run_test, "s/f") == 0)) { |
| 39503 | int i, j; |
| 39504 | static char code[] = "{\n\ |
| 39505 | short a = p1;\n\ |
| 39506 | float b = p2;\n\ |
| 39507 | return a / b;\n\ |
| 39508 | }"; |
| 39509 | |
| 39510 | short (*proc)(short a, float b); |
| 39511 | cod_parse_context context = new_cod_parse_context(); |
| 39512 | int dumped = 0; |
| 39513 | |
| 39514 | cod_code gen_code; |
| 39515 | |
| 39516 | /* test for short / float */ |
| 39517 | if (verbose) printf("test for short / float"); |
| 39518 | |
| 39519 | cod_assoc_externs(context, externs); |
| 39520 | cod_parse_for_context(extern_string, context); |
| 39521 | |
| 39522 | cod_subroutine_declaration("short proc(short p1, float p2)", |
| 39523 | context); |
| 39524 | gen_code = cod_code_gen(code, context); |
| 39525 | proc = (short (*)(short, float))(long)gen_code->func; |
| 39526 | |
| 39527 | |
| 39528 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 39529 | short source1_s = src1s_vals[i]; |
| 39530 | for (j=0 ; j < sizeof(src2f_vals)/sizeof(src2f_vals[0]) ; j++) { |
| 39531 | float source2_f = src2f_vals[j]; |
| 39532 | double range = 0.000001 * (fabs((double)source1_s / (double)source2_f)); |
| 39533 | short expected_result; |
| 39534 | short result; |
| 39535 | |
| 39536 | if (source2_f == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip156;} |
| 39537 | if ((source1_s/source2_f) < (-32768) || ((source1_s/source2_f) > 32767)){if (verbose) {printf("+");fflush(stdoutstdout);} goto skip156;} |
| 39538 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 39539 | |
| 39540 | expected_result = (short) (source1_s / source2_f); |
| 39541 | |
| 39542 | result = proc(source1_s, source2_f); |
| 39543 | range += 1.0; |
| 39544 | if ((result > (expected_result + range)) || (result < (expected_result - range))) { |
| 39545 | printf("Failed short / float test, expected %d, got %d, for %d / %g\n", |
| 39546 | expected_result, result, source1_s, source2_f); |
| 39547 | if (dumped == 0) cod_dump(gen_code); |
| 39548 | failed++; |
| 39549 | dumped++; |
| 39550 | } |
| 39551 | skip156: ; |
| 39552 | } |
| 39553 | } |
| 39554 | if (verbose) printf(" done\n"); |
| 39555 | cod_free_parse_context(context); |
| 39556 | cod_code_free(gen_code); |
| 39557 | } |
| 39558 | if ((only_run_test == NULL((void*)0)) || |
| 39559 | (strcmp(only_run_test, "s/d") == 0)) { |
| 39560 | int i, j; |
| 39561 | static char code[] = "{\n\ |
| 39562 | short a = p1;\n\ |
| 39563 | double b = p2;\n\ |
| 39564 | return a / b;\n\ |
| 39565 | }"; |
| 39566 | |
| 39567 | short (*proc)(short a, double b); |
| 39568 | cod_parse_context context = new_cod_parse_context(); |
| 39569 | int dumped = 0; |
| 39570 | |
| 39571 | cod_code gen_code; |
| 39572 | |
| 39573 | /* test for short / double */ |
| 39574 | if (verbose) printf("test for short / double"); |
| 39575 | |
| 39576 | cod_assoc_externs(context, externs); |
| 39577 | cod_parse_for_context(extern_string, context); |
| 39578 | |
| 39579 | cod_subroutine_declaration("short proc(short p1, double p2)", |
| 39580 | context); |
| 39581 | gen_code = cod_code_gen(code, context); |
| 39582 | proc = (short (*)(short, double))(long)gen_code->func; |
| 39583 | |
| 39584 | |
| 39585 | for (i=0 ; i < sizeof(src1s_vals)/sizeof(src1s_vals[0]) ; i++) { |
| 39586 | short source1_s = src1s_vals[i]; |
| 39587 | for (j=0 ; j < sizeof(src2d_vals)/sizeof(src2d_vals[0]) ; j++) { |
| 39588 | double source2_d = src2d_vals[j]; |
| 39589 | |
| 39590 | short expected_result; |
| 39591 | short result; |
| 39592 | |
| 39593 | if (source2_d == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip157;} |
| 39594 | if ((source1_s/source2_d) < (-32768) || ((source1_s/source2_d) > 32767)){if (verbose) {printf("+");fflush(stdoutstdout);} goto skip157;} |
| 39595 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 39596 | |
| 39597 | expected_result = (short) (source1_s / source2_d); |
| 39598 | |
| 39599 | result = proc(source1_s, source2_d); |
| 39600 | if (expected_result != result) { |
| 39601 | printf("Failed short / double test, expected %d, got %d, for %d / %g\n", |
| 39602 | expected_result, result, source1_s, source2_d); |
| 39603 | if (dumped == 0) cod_dump(gen_code); |
| 39604 | failed++; |
| 39605 | dumped++; |
| 39606 | } |
| 39607 | skip157: ; |
| 39608 | } |
| 39609 | } |
| 39610 | if (verbose) printf(" done\n"); |
| 39611 | cod_free_parse_context(context); |
| 39612 | cod_code_free(gen_code); |
| 39613 | } |
| 39614 | } |
| 39615 | void div_us_tests() |
| 39616 | { |
| 39617 | if ((only_run_test == NULL((void*)0)) || |
| 39618 | (strcmp(only_run_test, "us/c") == 0)) { |
| 39619 | int i, j; |
| 39620 | static char code[] = "{\n\ |
| 39621 | unsigned short a = p1;\n\ |
| 39622 | signed char b = p2;\n\ |
| 39623 | return a / b;\n\ |
| 39624 | }"; |
| 39625 | |
| 39626 | unsigned short (*proc)(unsigned short a, signed char b); |
| 39627 | cod_parse_context context = new_cod_parse_context(); |
| 39628 | int dumped = 0; |
| 39629 | |
| 39630 | cod_code gen_code; |
| 39631 | |
| 39632 | /* test for unsigned short / signed char */ |
| 39633 | if (verbose) printf("test for unsigned short / signed char"); |
| 39634 | |
| 39635 | cod_assoc_externs(context, externs); |
| 39636 | cod_parse_for_context(extern_string, context); |
| 39637 | |
| 39638 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, signed char p2)", |
| 39639 | context); |
| 39640 | gen_code = cod_code_gen(code, context); |
| 39641 | proc = (unsigned short (*)(unsigned short, signed char))(long)gen_code->func; |
| 39642 | |
| 39643 | |
| 39644 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 39645 | unsigned short source1_us = src1us_vals[i]; |
| 39646 | for (j=0 ; j < sizeof(src2c_vals)/sizeof(src2c_vals[0]) ; j++) { |
| 39647 | signed char source2_c = src2c_vals[j]; |
| 39648 | |
| 39649 | unsigned short expected_result; |
| 39650 | unsigned short result; |
| 39651 | |
| 39652 | if (source2_c == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip158;} |
| 39653 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 39654 | |
| 39655 | expected_result = (unsigned short) (source1_us / source2_c); |
| 39656 | |
| 39657 | result = proc(source1_us, source2_c); |
| 39658 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 39659 | if (expected_result != result) { |
| 39660 | printf("Failed unsigned short / signed char test, expected %u, got %u, for %u / %d\n", |
| 39661 | expected_result, result, source1_us, source2_c); |
| 39662 | if (dumped == 0) cod_dump(gen_code); |
| 39663 | failed++; |
| 39664 | dumped++; |
| 39665 | } |
| 39666 | skip158: ; |
| 39667 | } |
| 39668 | } |
| 39669 | if (verbose) printf(" done\n"); |
| 39670 | cod_free_parse_context(context); |
| 39671 | cod_code_free(gen_code); |
| 39672 | } |
| 39673 | if ((only_run_test == NULL((void*)0)) || |
| 39674 | (strcmp(only_run_test, "us/uc") == 0)) { |
| 39675 | int i, j; |
| 39676 | static char code[] = "{\n\ |
| 39677 | unsigned short a = p1;\n\ |
| 39678 | unsigned char b = p2;\n\ |
| 39679 | return a / b;\n\ |
| 39680 | }"; |
| 39681 | |
| 39682 | unsigned short (*proc)(unsigned short a, unsigned char b); |
| 39683 | cod_parse_context context = new_cod_parse_context(); |
| 39684 | int dumped = 0; |
| 39685 | |
| 39686 | cod_code gen_code; |
| 39687 | |
| 39688 | /* test for unsigned short / unsigned char */ |
| 39689 | if (verbose) printf("test for unsigned short / unsigned char"); |
| 39690 | |
| 39691 | cod_assoc_externs(context, externs); |
| 39692 | cod_parse_for_context(extern_string, context); |
| 39693 | |
| 39694 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, unsigned char p2)", |
| 39695 | context); |
| 39696 | gen_code = cod_code_gen(code, context); |
| 39697 | proc = (unsigned short (*)(unsigned short, unsigned char))(long)gen_code->func; |
| 39698 | |
| 39699 | |
| 39700 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 39701 | unsigned short source1_us = src1us_vals[i]; |
| 39702 | for (j=0 ; j < sizeof(src2uc_vals)/sizeof(src2uc_vals[0]) ; j++) { |
| 39703 | unsigned char source2_uc = src2uc_vals[j]; |
| 39704 | |
| 39705 | unsigned short expected_result; |
| 39706 | unsigned short result; |
| 39707 | |
| 39708 | if (source2_uc == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip159;} |
| 39709 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 39710 | |
| 39711 | expected_result = (unsigned short) (source1_us / source2_uc); |
| 39712 | |
| 39713 | result = proc(source1_us, source2_uc); |
| 39714 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 39715 | if (expected_result != result) { |
| 39716 | printf("Failed unsigned short / unsigned char test, expected %u, got %u, for %u / %u\n", |
| 39717 | expected_result, result, source1_us, source2_uc); |
| 39718 | if (dumped == 0) cod_dump(gen_code); |
| 39719 | failed++; |
| 39720 | dumped++; |
| 39721 | } |
| 39722 | skip159: ; |
| 39723 | } |
| 39724 | } |
| 39725 | if (verbose) printf(" done\n"); |
| 39726 | cod_free_parse_context(context); |
| 39727 | cod_code_free(gen_code); |
| 39728 | } |
| 39729 | if ((only_run_test == NULL((void*)0)) || |
| 39730 | (strcmp(only_run_test, "us/s") == 0)) { |
| 39731 | int i, j; |
| 39732 | static char code[] = "{\n\ |
| 39733 | unsigned short a = p1;\n\ |
| 39734 | short b = p2;\n\ |
| 39735 | return a / b;\n\ |
| 39736 | }"; |
| 39737 | |
| 39738 | unsigned short (*proc)(unsigned short a, short b); |
| 39739 | cod_parse_context context = new_cod_parse_context(); |
| 39740 | int dumped = 0; |
| 39741 | |
| 39742 | cod_code gen_code; |
| 39743 | |
| 39744 | /* test for unsigned short / short */ |
| 39745 | if (verbose) printf("test for unsigned short / short"); |
| 39746 | |
| 39747 | cod_assoc_externs(context, externs); |
| 39748 | cod_parse_for_context(extern_string, context); |
| 39749 | |
| 39750 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, short p2)", |
| 39751 | context); |
| 39752 | gen_code = cod_code_gen(code, context); |
| 39753 | proc = (unsigned short (*)(unsigned short, short))(long)gen_code->func; |
| 39754 | |
| 39755 | |
| 39756 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 39757 | unsigned short source1_us = src1us_vals[i]; |
| 39758 | for (j=0 ; j < sizeof(src2s_vals)/sizeof(src2s_vals[0]) ; j++) { |
| 39759 | short source2_s = src2s_vals[j]; |
| 39760 | |
| 39761 | unsigned short expected_result; |
| 39762 | unsigned short result; |
| 39763 | |
| 39764 | if (source2_s == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip160;} |
| 39765 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 39766 | |
| 39767 | expected_result = (unsigned short) (source1_us / source2_s); |
| 39768 | |
| 39769 | result = proc(source1_us, source2_s); |
| 39770 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 39771 | if (expected_result != result) { |
| 39772 | printf("Failed unsigned short / short test, expected %u, got %u, for %u / %d\n", |
| 39773 | expected_result, result, source1_us, source2_s); |
| 39774 | if (dumped == 0) cod_dump(gen_code); |
| 39775 | failed++; |
| 39776 | dumped++; |
| 39777 | } |
| 39778 | skip160: ; |
| 39779 | } |
| 39780 | } |
| 39781 | if (verbose) printf(" done\n"); |
| 39782 | cod_free_parse_context(context); |
| 39783 | cod_code_free(gen_code); |
| 39784 | } |
| 39785 | if ((only_run_test == NULL((void*)0)) || |
| 39786 | (strcmp(only_run_test, "us/us") == 0)) { |
| 39787 | int i, j; |
| 39788 | static char code[] = "{\n\ |
| 39789 | unsigned short a = p1;\n\ |
| 39790 | unsigned short b = p2;\n\ |
| 39791 | return a / b;\n\ |
| 39792 | }"; |
| 39793 | |
| 39794 | unsigned short (*proc)(unsigned short a, unsigned short b); |
| 39795 | cod_parse_context context = new_cod_parse_context(); |
| 39796 | int dumped = 0; |
| 39797 | |
| 39798 | cod_code gen_code; |
| 39799 | |
| 39800 | /* test for unsigned short / unsigned short */ |
| 39801 | if (verbose) printf("test for unsigned short / unsigned short"); |
| 39802 | |
| 39803 | cod_assoc_externs(context, externs); |
| 39804 | cod_parse_for_context(extern_string, context); |
| 39805 | |
| 39806 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, unsigned short p2)", |
| 39807 | context); |
| 39808 | gen_code = cod_code_gen(code, context); |
| 39809 | proc = (unsigned short (*)(unsigned short, unsigned short))(long)gen_code->func; |
| 39810 | |
| 39811 | |
| 39812 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 39813 | unsigned short source1_us = src1us_vals[i]; |
| 39814 | for (j=0 ; j < sizeof(src2us_vals)/sizeof(src2us_vals[0]) ; j++) { |
| 39815 | unsigned short source2_us = src2us_vals[j]; |
| 39816 | |
| 39817 | unsigned short expected_result; |
| 39818 | unsigned short result; |
| 39819 | |
| 39820 | if (source2_us == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip161;} |
| 39821 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 39822 | |
| 39823 | expected_result = (unsigned short) (source1_us / source2_us); |
| 39824 | |
| 39825 | result = proc(source1_us, source2_us); |
| 39826 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 39827 | if (expected_result != result) { |
| 39828 | printf("Failed unsigned short / unsigned short test, expected %u, got %u, for %u / %u\n", |
| 39829 | expected_result, result, source1_us, source2_us); |
| 39830 | if (dumped == 0) cod_dump(gen_code); |
| 39831 | failed++; |
| 39832 | dumped++; |
| 39833 | } |
| 39834 | skip161: ; |
| 39835 | } |
| 39836 | } |
| 39837 | if (verbose) printf(" done\n"); |
| 39838 | cod_free_parse_context(context); |
| 39839 | cod_code_free(gen_code); |
| 39840 | } |
| 39841 | if ((only_run_test == NULL((void*)0)) || |
| 39842 | (strcmp(only_run_test, "us/i") == 0)) { |
| 39843 | int i, j; |
| 39844 | static char code[] = "{\n\ |
| 39845 | unsigned short a = p1;\n\ |
| 39846 | int b = p2;\n\ |
| 39847 | return a / b;\n\ |
| 39848 | }"; |
| 39849 | |
| 39850 | unsigned short (*proc)(unsigned short a, int b); |
| 39851 | cod_parse_context context = new_cod_parse_context(); |
| 39852 | int dumped = 0; |
| 39853 | |
| 39854 | cod_code gen_code; |
| 39855 | |
| 39856 | /* test for unsigned short / int */ |
| 39857 | if (verbose) printf("test for unsigned short / int"); |
| 39858 | |
| 39859 | cod_assoc_externs(context, externs); |
| 39860 | cod_parse_for_context(extern_string, context); |
| 39861 | |
| 39862 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, int p2)", |
| 39863 | context); |
| 39864 | gen_code = cod_code_gen(code, context); |
| 39865 | proc = (unsigned short (*)(unsigned short, int))(long)gen_code->func; |
| 39866 | |
| 39867 | |
| 39868 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 39869 | unsigned short source1_us = src1us_vals[i]; |
| 39870 | for (j=0 ; j < sizeof(src2i_vals)/sizeof(src2i_vals[0]) ; j++) { |
| 39871 | int source2_i = src2i_vals[j]; |
| 39872 | |
| 39873 | unsigned short expected_result; |
| 39874 | unsigned short result; |
| 39875 | |
| 39876 | if (source2_i == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip162;} |
| 39877 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 39878 | |
| 39879 | expected_result = (unsigned short) (source1_us / source2_i); |
| 39880 | |
| 39881 | result = proc(source1_us, source2_i); |
| 39882 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 39883 | if (expected_result != result) { |
| 39884 | printf("Failed unsigned short / int test, expected %u, got %u, for %u / %d\n", |
| 39885 | expected_result, result, source1_us, source2_i); |
| 39886 | if (dumped == 0) cod_dump(gen_code); |
| 39887 | failed++; |
| 39888 | dumped++; |
| 39889 | } |
| 39890 | skip162: ; |
| 39891 | } |
| 39892 | } |
| 39893 | if (verbose) printf(" done\n"); |
| 39894 | cod_free_parse_context(context); |
| 39895 | cod_code_free(gen_code); |
| 39896 | } |
| 39897 | if ((only_run_test == NULL((void*)0)) || |
| 39898 | (strcmp(only_run_test, "us/u") == 0)) { |
| 39899 | int i, j; |
| 39900 | static char code[] = "{\n\ |
| 39901 | unsigned short a = p1;\n\ |
| 39902 | unsigned int b = p2;\n\ |
| 39903 | return a / b;\n\ |
| 39904 | }"; |
| 39905 | |
| 39906 | unsigned short (*proc)(unsigned short a, unsigned int b); |
| 39907 | cod_parse_context context = new_cod_parse_context(); |
| 39908 | int dumped = 0; |
| 39909 | |
| 39910 | cod_code gen_code; |
| 39911 | |
| 39912 | /* test for unsigned short / unsigned int */ |
| 39913 | if (verbose) printf("test for unsigned short / unsigned int"); |
| 39914 | |
| 39915 | cod_assoc_externs(context, externs); |
| 39916 | cod_parse_for_context(extern_string, context); |
| 39917 | |
| 39918 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, unsigned int p2)", |
| 39919 | context); |
| 39920 | gen_code = cod_code_gen(code, context); |
| 39921 | proc = (unsigned short (*)(unsigned short, unsigned int))(long)gen_code->func; |
| 39922 | |
| 39923 | |
| 39924 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 39925 | unsigned short source1_us = src1us_vals[i]; |
| 39926 | for (j=0 ; j < sizeof(src2u_vals)/sizeof(src2u_vals[0]) ; j++) { |
| 39927 | unsigned int source2_u = src2u_vals[j]; |
| 39928 | |
| 39929 | unsigned short expected_result; |
| 39930 | unsigned short result; |
| 39931 | |
| 39932 | if (source2_u == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip163;} |
| 39933 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 39934 | |
| 39935 | expected_result = (unsigned short) (source1_us / source2_u); |
| 39936 | |
| 39937 | result = proc(source1_us, source2_u); |
| 39938 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 39939 | if (expected_result != result) { |
| 39940 | printf("Failed unsigned short / unsigned int test, expected %u, got %u, for %u / %u\n", |
| 39941 | expected_result, result, source1_us, source2_u); |
| 39942 | if (dumped == 0) cod_dump(gen_code); |
| 39943 | failed++; |
| 39944 | dumped++; |
| 39945 | } |
| 39946 | skip163: ; |
| 39947 | } |
| 39948 | } |
| 39949 | if (verbose) printf(" done\n"); |
| 39950 | cod_free_parse_context(context); |
| 39951 | cod_code_free(gen_code); |
| 39952 | } |
| 39953 | if ((only_run_test == NULL((void*)0)) || |
| 39954 | (strcmp(only_run_test, "us/ul") == 0)) { |
| 39955 | int i, j; |
| 39956 | static char code[] = "{\n\ |
| 39957 | unsigned short a = p1;\n\ |
| 39958 | unsigned long b = p2;\n\ |
| 39959 | return a / b;\n\ |
| 39960 | }"; |
| 39961 | |
| 39962 | unsigned short (*proc)(unsigned short a, unsigned long b); |
| 39963 | cod_parse_context context = new_cod_parse_context(); |
| 39964 | int dumped = 0; |
| 39965 | |
| 39966 | cod_code gen_code; |
| 39967 | |
| 39968 | /* test for unsigned short / unsigned long */ |
| 39969 | if (verbose) printf("test for unsigned short / unsigned long"); |
| 39970 | |
| 39971 | cod_assoc_externs(context, externs); |
| 39972 | cod_parse_for_context(extern_string, context); |
| 39973 | |
| 39974 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, unsigned long p2)", |
| 39975 | context); |
| 39976 | gen_code = cod_code_gen(code, context); |
| 39977 | proc = (unsigned short (*)(unsigned short, unsigned long))(long)gen_code->func; |
| 39978 | |
| 39979 | |
| 39980 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 39981 | unsigned short source1_us = src1us_vals[i]; |
| 39982 | for (j=0 ; j < sizeof(src2ul_vals)/sizeof(src2ul_vals[0]) ; j++) { |
| 39983 | unsigned long source2_ul = src2ul_vals[j]; |
| 39984 | |
| 39985 | unsigned short expected_result; |
| 39986 | unsigned short result; |
| 39987 | |
| 39988 | if (source2_ul == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip164;} |
| 39989 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 39990 | |
| 39991 | expected_result = (unsigned short) (source1_us / source2_ul); |
| 39992 | |
| 39993 | result = proc(source1_us, source2_ul); |
| 39994 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 39995 | if (expected_result != result) { |
| 39996 | printf("Failed unsigned short / unsigned long test, expected %u, got %u, for %u / %lu\n", |
| 39997 | expected_result, result, source1_us, source2_ul); |
| 39998 | if (dumped == 0) cod_dump(gen_code); |
| 39999 | failed++; |
| 40000 | dumped++; |
| 40001 | } |
| 40002 | skip164: ; |
| 40003 | } |
| 40004 | } |
| 40005 | if (verbose) printf(" done\n"); |
| 40006 | cod_free_parse_context(context); |
| 40007 | cod_code_free(gen_code); |
| 40008 | } |
| 40009 | if ((only_run_test == NULL((void*)0)) || |
| 40010 | (strcmp(only_run_test, "us/l") == 0)) { |
| 40011 | int i, j; |
| 40012 | static char code[] = "{\n\ |
| 40013 | unsigned short a = p1;\n\ |
| 40014 | long b = p2;\n\ |
| 40015 | return a / b;\n\ |
| 40016 | }"; |
| 40017 | |
| 40018 | unsigned short (*proc)(unsigned short a, long b); |
| 40019 | cod_parse_context context = new_cod_parse_context(); |
| 40020 | int dumped = 0; |
| 40021 | |
| 40022 | cod_code gen_code; |
| 40023 | |
| 40024 | /* test for unsigned short / long */ |
| 40025 | if (verbose) printf("test for unsigned short / long"); |
| 40026 | |
| 40027 | cod_assoc_externs(context, externs); |
| 40028 | cod_parse_for_context(extern_string, context); |
| 40029 | |
| 40030 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, long p2)", |
| 40031 | context); |
| 40032 | gen_code = cod_code_gen(code, context); |
| 40033 | proc = (unsigned short (*)(unsigned short, long))(long)gen_code->func; |
| 40034 | |
| 40035 | |
| 40036 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 40037 | unsigned short source1_us = src1us_vals[i]; |
| 40038 | for (j=0 ; j < sizeof(src2l_vals)/sizeof(src2l_vals[0]) ; j++) { |
| 40039 | long source2_l = src2l_vals[j]; |
| 40040 | |
| 40041 | unsigned short expected_result; |
| 40042 | unsigned short result; |
| 40043 | |
| 40044 | if (source2_l == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip165;} |
| 40045 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 40046 | |
| 40047 | expected_result = (unsigned short) (source1_us / source2_l); |
| 40048 | |
| 40049 | result = proc(source1_us, source2_l); |
| 40050 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 40051 | if (expected_result != result) { |
| 40052 | printf("Failed unsigned short / long test, expected %u, got %u, for %u / %ld\n", |
| 40053 | expected_result, result, source1_us, source2_l); |
| 40054 | if (dumped == 0) cod_dump(gen_code); |
| 40055 | failed++; |
| 40056 | dumped++; |
| 40057 | } |
| 40058 | skip165: ; |
| 40059 | } |
| 40060 | } |
| 40061 | if (verbose) printf(" done\n"); |
| 40062 | cod_free_parse_context(context); |
| 40063 | cod_code_free(gen_code); |
| 40064 | } |
| 40065 | if ((only_run_test == NULL((void*)0)) || |
| 40066 | (strcmp(only_run_test, "us/f") == 0)) { |
| 40067 | int i, j; |
| 40068 | static char code[] = "{\n\ |
| 40069 | unsigned short a = p1;\n\ |
| 40070 | float b = p2;\n\ |
| 40071 | return a / b;\n\ |
| 40072 | }"; |
| 40073 | |
| 40074 | unsigned short (*proc)(unsigned short a, float b); |
| 40075 | cod_parse_context context = new_cod_parse_context(); |
| 40076 | int dumped = 0; |
| 40077 | |
| 40078 | cod_code gen_code; |
| 40079 | |
| 40080 | /* test for unsigned short / float */ |
| 40081 | if (verbose) printf("test for unsigned short / float"); |
| 40082 | |
| 40083 | cod_assoc_externs(context, externs); |
| 40084 | cod_parse_for_context(extern_string, context); |
| 40085 | |
| 40086 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, float p2)", |
| 40087 | context); |
| 40088 | gen_code = cod_code_gen(code, context); |
| 40089 | proc = (unsigned short (*)(unsigned short, float))(long)gen_code->func; |
| 40090 | |
| 40091 | |
| 40092 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 40093 | unsigned short source1_us = src1us_vals[i]; |
| 40094 | for (j=0 ; j < sizeof(src2f_vals)/sizeof(src2f_vals[0]) ; j++) { |
| 40095 | float source2_f = src2f_vals[j]; |
| 40096 | double range = 0.000001 * (fabs((double)source1_us / (double)source2_f)); |
| 40097 | unsigned short expected_result; |
| 40098 | unsigned short result; |
| 40099 | |
| 40100 | if (source2_f == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip166;} |
| 40101 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 40102 | |
| 40103 | expected_result = (unsigned short) (source1_us / source2_f); |
| 40104 | |
| 40105 | result = proc(source1_us, source2_f); |
| 40106 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 40107 | range += 1.0; |
| 40108 | if ((result > (expected_result + range)) || (result < (expected_result - range))) { |
| 40109 | printf("Failed unsigned short / float test, expected %u, got %u, for %u / %g\n", |
| 40110 | expected_result, result, source1_us, source2_f); |
| 40111 | if (dumped == 0) cod_dump(gen_code); |
| 40112 | failed++; |
| 40113 | dumped++; |
| 40114 | } |
| 40115 | skip166: ; |
| 40116 | } |
| 40117 | } |
| 40118 | if (verbose) printf(" done\n"); |
| 40119 | cod_free_parse_context(context); |
| 40120 | cod_code_free(gen_code); |
| 40121 | } |
| 40122 | if ((only_run_test == NULL((void*)0)) || |
| 40123 | (strcmp(only_run_test, "us/d") == 0)) { |
| 40124 | int i, j; |
| 40125 | static char code[] = "{\n\ |
| 40126 | unsigned short a = p1;\n\ |
| 40127 | double b = p2;\n\ |
| 40128 | return a / b;\n\ |
| 40129 | }"; |
| 40130 | |
| 40131 | unsigned short (*proc)(unsigned short a, double b); |
| 40132 | cod_parse_context context = new_cod_parse_context(); |
| 40133 | int dumped = 0; |
| 40134 | |
| 40135 | cod_code gen_code; |
| 40136 | |
| 40137 | /* test for unsigned short / double */ |
| 40138 | if (verbose) printf("test for unsigned short / double"); |
| 40139 | |
| 40140 | cod_assoc_externs(context, externs); |
| 40141 | cod_parse_for_context(extern_string, context); |
| 40142 | |
| 40143 | cod_subroutine_declaration("unsigned short proc(unsigned short p1, double p2)", |
| 40144 | context); |
| 40145 | gen_code = cod_code_gen(code, context); |
| 40146 | proc = (unsigned short (*)(unsigned short, double))(long)gen_code->func; |
| 40147 | |
| 40148 | |
| 40149 | for (i=0 ; i < sizeof(src1us_vals)/sizeof(src1us_vals[0]) ; i++) { |
| 40150 | unsigned short source1_us = src1us_vals[i]; |
| 40151 | for (j=0 ; j < sizeof(src2d_vals)/sizeof(src2d_vals[0]) ; j++) { |
| 40152 | double source2_d = src2d_vals[j]; |
| 40153 | |
| 40154 | unsigned short expected_result; |
| 40155 | unsigned short result; |
| 40156 | |
| 40157 | if (source2_d == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip167;} |
| 40158 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 40159 | |
| 40160 | expected_result = (unsigned short) (source1_us / source2_d); |
| 40161 | |
| 40162 | result = proc(source1_us, source2_d); |
| 40163 | if ((expected_result == 0) || (expected_result == (unsigned short) 0xffff) || (expected_result == (unsigned short) 0x8000)) continue; |
| 40164 | if (expected_result != result) { |
| 40165 | printf("Failed unsigned short / double test, expected %u, got %u, for %u / %g\n", |
| 40166 | expected_result, result, source1_us, source2_d); |
| 40167 | if (dumped == 0) cod_dump(gen_code); |
| 40168 | failed++; |
| 40169 | dumped++; |
| 40170 | } |
| 40171 | skip167: ; |
| 40172 | } |
| 40173 | } |
| 40174 | if (verbose) printf(" done\n"); |
| 40175 | cod_free_parse_context(context); |
| 40176 | cod_code_free(gen_code); |
| 40177 | } |
| 40178 | } |
| 40179 | void div_i_tests() |
| 40180 | { |
| 40181 | if ((only_run_test == NULL((void*)0)) || |
| 40182 | (strcmp(only_run_test, "i/c") == 0)) { |
| 40183 | int i, j; |
| 40184 | static char code[] = "{\n\ |
| 40185 | int a = p1;\n\ |
| 40186 | signed char b = p2;\n\ |
| 40187 | return a / b;\n\ |
| 40188 | }"; |
| 40189 | |
| 40190 | int (*proc)(int a, signed char b); |
| 40191 | cod_parse_context context = new_cod_parse_context(); |
| 40192 | int dumped = 0; |
| 40193 | |
| 40194 | cod_code gen_code; |
| 40195 | |
| 40196 | /* test for int / signed char */ |
| 40197 | if (verbose) printf("test for int / signed char"); |
| 40198 | |
| 40199 | cod_assoc_externs(context, externs); |
| 40200 | cod_parse_for_context(extern_string, context); |
| 40201 | |
| 40202 | cod_subroutine_declaration("int proc(int p1, signed char p2)", |
| 40203 | context); |
| 40204 | gen_code = cod_code_gen(code, context); |
| 40205 | proc = (int (*)(int, signed char))(long)gen_code->func; |
| 40206 | |
| 40207 | |
| 40208 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 40209 | int source1_i = src1i_vals[i]; |
| 40210 | for (j=0 ; j < sizeof(src2c_vals)/sizeof(src2c_vals[0]) ; j++) { |
| 40211 | signed char source2_c = src2c_vals[j]; |
| 40212 | |
| 40213 | int expected_result; |
| 40214 | int result; |
| 40215 | |
| 40216 | if (source2_c == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip168;} |
| 40217 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 40218 | |
| 40219 | expected_result = (int) (source1_i / source2_c); |
| 40220 | |
| 40221 | result = proc(source1_i, source2_c); |
| 40222 | if (expected_result != result) { |
| 40223 | printf("Failed int / signed char test, expected %d, got %d, for %d / %d\n", |
| 40224 | expected_result, result, source1_i, source2_c); |
| 40225 | if (dumped == 0) cod_dump(gen_code); |
| 40226 | failed++; |
| 40227 | dumped++; |
| 40228 | } |
| 40229 | skip168: ; |
| 40230 | } |
| 40231 | } |
| 40232 | if (verbose) printf(" done\n"); |
| 40233 | cod_free_parse_context(context); |
| 40234 | cod_code_free(gen_code); |
| 40235 | } |
| 40236 | if ((only_run_test == NULL((void*)0)) || |
| 40237 | (strcmp(only_run_test, "i/uc") == 0)) { |
| 40238 | int i, j; |
| 40239 | static char code[] = "{\n\ |
| 40240 | int a = p1;\n\ |
| 40241 | unsigned char b = p2;\n\ |
| 40242 | return a / b;\n\ |
| 40243 | }"; |
| 40244 | |
| 40245 | int (*proc)(int a, unsigned char b); |
| 40246 | cod_parse_context context = new_cod_parse_context(); |
| 40247 | int dumped = 0; |
| 40248 | |
| 40249 | cod_code gen_code; |
| 40250 | |
| 40251 | /* test for int / unsigned char */ |
| 40252 | if (verbose) printf("test for int / unsigned char"); |
| 40253 | |
| 40254 | cod_assoc_externs(context, externs); |
| 40255 | cod_parse_for_context(extern_string, context); |
| 40256 | |
| 40257 | cod_subroutine_declaration("int proc(int p1, unsigned char p2)", |
| 40258 | context); |
| 40259 | gen_code = cod_code_gen(code, context); |
| 40260 | proc = (int (*)(int, unsigned char))(long)gen_code->func; |
| 40261 | |
| 40262 | |
| 40263 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 40264 | int source1_i = src1i_vals[i]; |
| 40265 | for (j=0 ; j < sizeof(src2uc_vals)/sizeof(src2uc_vals[0]) ; j++) { |
| 40266 | unsigned char source2_uc = src2uc_vals[j]; |
| 40267 | |
| 40268 | int expected_result; |
| 40269 | int result; |
| 40270 | |
| 40271 | if (source2_uc == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip169;} |
| 40272 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 40273 | |
| 40274 | expected_result = (int) (source1_i / source2_uc); |
| 40275 | |
| 40276 | result = proc(source1_i, source2_uc); |
| 40277 | if (expected_result != result) { |
| 40278 | printf("Failed int / unsigned char test, expected %d, got %d, for %d / %u\n", |
| 40279 | expected_result, result, source1_i, source2_uc); |
| 40280 | if (dumped == 0) cod_dump(gen_code); |
| 40281 | failed++; |
| 40282 | dumped++; |
| 40283 | } |
| 40284 | skip169: ; |
| 40285 | } |
| 40286 | } |
| 40287 | if (verbose) printf(" done\n"); |
| 40288 | cod_free_parse_context(context); |
| 40289 | cod_code_free(gen_code); |
| 40290 | } |
| 40291 | if ((only_run_test == NULL((void*)0)) || |
| 40292 | (strcmp(only_run_test, "i/s") == 0)) { |
| 40293 | int i, j; |
| 40294 | static char code[] = "{\n\ |
| 40295 | int a = p1;\n\ |
| 40296 | short b = p2;\n\ |
| 40297 | return a / b;\n\ |
| 40298 | }"; |
| 40299 | |
| 40300 | int (*proc)(int a, short b); |
| 40301 | cod_parse_context context = new_cod_parse_context(); |
| 40302 | int dumped = 0; |
| 40303 | |
| 40304 | cod_code gen_code; |
| 40305 | |
| 40306 | /* test for int / short */ |
| 40307 | if (verbose) printf("test for int / short"); |
| 40308 | |
| 40309 | cod_assoc_externs(context, externs); |
| 40310 | cod_parse_for_context(extern_string, context); |
| 40311 | |
| 40312 | cod_subroutine_declaration("int proc(int p1, short p2)", |
| 40313 | context); |
| 40314 | gen_code = cod_code_gen(code, context); |
| 40315 | proc = (int (*)(int, short))(long)gen_code->func; |
| 40316 | |
| 40317 | |
| 40318 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 40319 | int source1_i = src1i_vals[i]; |
| 40320 | for (j=0 ; j < sizeof(src2s_vals)/sizeof(src2s_vals[0]) ; j++) { |
| 40321 | short source2_s = src2s_vals[j]; |
| 40322 | |
| 40323 | int expected_result; |
| 40324 | int result; |
| 40325 | |
| 40326 | if (source2_s == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip170;} |
| 40327 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 40328 | |
| 40329 | expected_result = (int) (source1_i / source2_s); |
| 40330 | |
| 40331 | result = proc(source1_i, source2_s); |
| 40332 | if (expected_result != result) { |
| 40333 | printf("Failed int / short test, expected %d, got %d, for %d / %d\n", |
| 40334 | expected_result, result, source1_i, source2_s); |
| 40335 | if (dumped == 0) cod_dump(gen_code); |
| 40336 | failed++; |
| 40337 | dumped++; |
| 40338 | } |
| 40339 | skip170: ; |
| 40340 | } |
| 40341 | } |
| 40342 | if (verbose) printf(" done\n"); |
| 40343 | cod_free_parse_context(context); |
| 40344 | cod_code_free(gen_code); |
| 40345 | } |
| 40346 | if ((only_run_test == NULL((void*)0)) || |
| 40347 | (strcmp(only_run_test, "i/us") == 0)) { |
| 40348 | int i, j; |
| 40349 | static char code[] = "{\n\ |
| 40350 | int a = p1;\n\ |
| 40351 | unsigned short b = p2;\n\ |
| 40352 | return a / b;\n\ |
| 40353 | }"; |
| 40354 | |
| 40355 | int (*proc)(int a, unsigned short b); |
| 40356 | cod_parse_context context = new_cod_parse_context(); |
| 40357 | int dumped = 0; |
| 40358 | |
| 40359 | cod_code gen_code; |
| 40360 | |
| 40361 | /* test for int / unsigned short */ |
| 40362 | if (verbose) printf("test for int / unsigned short"); |
| 40363 | |
| 40364 | cod_assoc_externs(context, externs); |
| 40365 | cod_parse_for_context(extern_string, context); |
| 40366 | |
| 40367 | cod_subroutine_declaration("int proc(int p1, unsigned short p2)", |
| 40368 | context); |
| 40369 | gen_code = cod_code_gen(code, context); |
| 40370 | proc = (int (*)(int, unsigned short))(long)gen_code->func; |
| 40371 | |
| 40372 | |
| 40373 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 40374 | int source1_i = src1i_vals[i]; |
| 40375 | for (j=0 ; j < sizeof(src2us_vals)/sizeof(src2us_vals[0]) ; j++) { |
| 40376 | unsigned short source2_us = src2us_vals[j]; |
| 40377 | |
| 40378 | int expected_result; |
| 40379 | int result; |
| 40380 | |
| 40381 | if (source2_us == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip171;} |
| 40382 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 40383 | |
| 40384 | expected_result = (int) (source1_i / source2_us); |
| 40385 | |
| 40386 | result = proc(source1_i, source2_us); |
| 40387 | if (expected_result != result) { |
| 40388 | printf("Failed int / unsigned short test, expected %d, got %d, for %d / %u\n", |
| 40389 | expected_result, result, source1_i, source2_us); |
| 40390 | if (dumped == 0) cod_dump(gen_code); |
| 40391 | failed++; |
| 40392 | dumped++; |
| 40393 | } |
| 40394 | skip171: ; |
| 40395 | } |
| 40396 | } |
| 40397 | if (verbose) printf(" done\n"); |
| 40398 | cod_free_parse_context(context); |
| 40399 | cod_code_free(gen_code); |
| 40400 | } |
| 40401 | if ((only_run_test == NULL((void*)0)) || |
| 40402 | (strcmp(only_run_test, "i/i") == 0)) { |
| 40403 | int i, j; |
| 40404 | static char code[] = "{\n\ |
| 40405 | int a = p1;\n\ |
| 40406 | int b = p2;\n\ |
| 40407 | return a / b;\n\ |
| 40408 | }"; |
| 40409 | |
| 40410 | int (*proc)(int a, int b); |
| 40411 | cod_parse_context context = new_cod_parse_context(); |
| 40412 | int dumped = 0; |
| 40413 | |
| 40414 | cod_code gen_code; |
| 40415 | |
| 40416 | /* test for int / int */ |
| 40417 | if (verbose) printf("test for int / int"); |
| 40418 | |
| 40419 | cod_assoc_externs(context, externs); |
| 40420 | cod_parse_for_context(extern_string, context); |
| 40421 | |
| 40422 | cod_subroutine_declaration("int proc(int p1, int p2)", |
| 40423 | context); |
| 40424 | gen_code = cod_code_gen(code, context); |
| 40425 | proc = (int (*)(int, int))(long)gen_code->func; |
| 40426 | |
| 40427 | |
| 40428 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 40429 | int source1_i = src1i_vals[i]; |
| 40430 | for (j=0 ; j < sizeof(src2i_vals)/sizeof(src2i_vals[0]) ; j++) { |
| 40431 | int source2_i = src2i_vals[j]; |
| 40432 | |
| 40433 | int expected_result; |
| 40434 | int result; |
| 40435 | |
| 40436 | if (source2_i == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip172;} |
| 40437 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 40438 | |
| 40439 | expected_result = (int) (source1_i / source2_i); |
| 40440 | |
| 40441 | result = proc(source1_i, source2_i); |
| 40442 | if (expected_result != result) { |
| 40443 | printf("Failed int / int test, expected %d, got %d, for %d / %d\n", |
| 40444 | expected_result, result, source1_i, source2_i); |
| 40445 | if (dumped == 0) cod_dump(gen_code); |
| 40446 | failed++; |
| 40447 | dumped++; |
| 40448 | } |
| 40449 | skip172: ; |
| 40450 | } |
| 40451 | } |
| 40452 | if (verbose) printf(" done\n"); |
| 40453 | cod_free_parse_context(context); |
| 40454 | cod_code_free(gen_code); |
| 40455 | } |
| 40456 | if ((only_run_test == NULL((void*)0)) || |
| 40457 | (strcmp(only_run_test, "i/u") == 0)) { |
| 40458 | int i, j; |
| 40459 | static char code[] = "{\n\ |
| 40460 | int a = p1;\n\ |
| 40461 | unsigned int b = p2;\n\ |
| 40462 | return a / b;\n\ |
| 40463 | }"; |
| 40464 | |
| 40465 | int (*proc)(int a, unsigned int b); |
| 40466 | cod_parse_context context = new_cod_parse_context(); |
| 40467 | int dumped = 0; |
| 40468 | |
| 40469 | cod_code gen_code; |
| 40470 | |
| 40471 | /* test for int / unsigned int */ |
| 40472 | if (verbose) printf("test for int / unsigned int"); |
| 40473 | |
| 40474 | cod_assoc_externs(context, externs); |
| 40475 | cod_parse_for_context(extern_string, context); |
| 40476 | |
| 40477 | cod_subroutine_declaration("int proc(int p1, unsigned int p2)", |
| 40478 | context); |
| 40479 | gen_code = cod_code_gen(code, context); |
| 40480 | proc = (int (*)(int, unsigned int))(long)gen_code->func; |
| 40481 | |
| 40482 | |
| 40483 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 40484 | int source1_i = src1i_vals[i]; |
| 40485 | for (j=0 ; j < sizeof(src2u_vals)/sizeof(src2u_vals[0]) ; j++) { |
| 40486 | unsigned int source2_u = src2u_vals[j]; |
| 40487 | |
| 40488 | int expected_result; |
| 40489 | int result; |
| 40490 | |
| 40491 | if (source2_u == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip173;} |
| 40492 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 40493 | |
| 40494 | expected_result = (int) (source1_i / source2_u); |
| 40495 | |
| 40496 | result = proc(source1_i, source2_u); |
| 40497 | if (expected_result != result) { |
| 40498 | printf("Failed int / unsigned int test, expected %d, got %d, for %d / %u\n", |
| 40499 | expected_result, result, source1_i, source2_u); |
| 40500 | if (dumped == 0) cod_dump(gen_code); |
| 40501 | failed++; |
| 40502 | dumped++; |
| 40503 | } |
| 40504 | skip173: ; |
| 40505 | } |
| 40506 | } |
| 40507 | if (verbose) printf(" done\n"); |
| 40508 | cod_free_parse_context(context); |
| 40509 | cod_code_free(gen_code); |
| 40510 | } |
| 40511 | if ((only_run_test == NULL((void*)0)) || |
| 40512 | (strcmp(only_run_test, "i/ul") == 0)) { |
| 40513 | int i, j; |
| 40514 | static char code[] = "{\n\ |
| 40515 | int a = p1;\n\ |
| 40516 | unsigned long b = p2;\n\ |
| 40517 | return a / b;\n\ |
| 40518 | }"; |
| 40519 | |
| 40520 | int (*proc)(int a, unsigned long b); |
| 40521 | cod_parse_context context = new_cod_parse_context(); |
| 40522 | int dumped = 0; |
| 40523 | |
| 40524 | cod_code gen_code; |
| 40525 | |
| 40526 | /* test for int / unsigned long */ |
| 40527 | if (verbose) printf("test for int / unsigned long"); |
| 40528 | |
| 40529 | cod_assoc_externs(context, externs); |
| 40530 | cod_parse_for_context(extern_string, context); |
| 40531 | |
| 40532 | cod_subroutine_declaration("int proc(int p1, unsigned long p2)", |
| 40533 | context); |
| 40534 | gen_code = cod_code_gen(code, context); |
| 40535 | proc = (int (*)(int, unsigned long))(long)gen_code->func; |
| 40536 | |
| 40537 | |
| 40538 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 40539 | int source1_i = src1i_vals[i]; |
| 40540 | for (j=0 ; j < sizeof(src2ul_vals)/sizeof(src2ul_vals[0]) ; j++) { |
| 40541 | unsigned long source2_ul = src2ul_vals[j]; |
| 40542 | |
| 40543 | int expected_result; |
| 40544 | int result; |
| 40545 | |
| 40546 | if (source2_ul == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip174;} |
| 40547 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 40548 | |
| 40549 | expected_result = (int) (source1_i / source2_ul); |
| 40550 | |
| 40551 | result = proc(source1_i, source2_ul); |
| 40552 | if (expected_result != result) { |
| 40553 | printf("Failed int / unsigned long test, expected %d, got %d, for %d / %lu\n", |
| 40554 | expected_result, result, source1_i, source2_ul); |
| 40555 | if (dumped == 0) cod_dump(gen_code); |
| 40556 | failed++; |
| 40557 | dumped++; |
| 40558 | } |
| 40559 | skip174: ; |
| 40560 | } |
| 40561 | } |
| 40562 | if (verbose) printf(" done\n"); |
| 40563 | cod_free_parse_context(context); |
| 40564 | cod_code_free(gen_code); |
| 40565 | } |
| 40566 | if ((only_run_test == NULL((void*)0)) || |
| 40567 | (strcmp(only_run_test, "i/l") == 0)) { |
| 40568 | int i, j; |
| 40569 | static char code[] = "{\n\ |
| 40570 | int a = p1;\n\ |
| 40571 | long b = p2;\n\ |
| 40572 | return a / b;\n\ |
| 40573 | }"; |
| 40574 | |
| 40575 | int (*proc)(int a, long b); |
| 40576 | cod_parse_context context = new_cod_parse_context(); |
| 40577 | int dumped = 0; |
| 40578 | |
| 40579 | cod_code gen_code; |
| 40580 | |
| 40581 | /* test for int / long */ |
| 40582 | if (verbose) printf("test for int / long"); |
| 40583 | |
| 40584 | cod_assoc_externs(context, externs); |
| 40585 | cod_parse_for_context(extern_string, context); |
| 40586 | |
| 40587 | cod_subroutine_declaration("int proc(int p1, long p2)", |
| 40588 | context); |
| 40589 | gen_code = cod_code_gen(code, context); |
| 40590 | proc = (int (*)(int, long))(long)gen_code->func; |
| 40591 | |
| 40592 | |
| 40593 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 40594 | int source1_i = src1i_vals[i]; |
| 40595 | for (j=0 ; j < sizeof(src2l_vals)/sizeof(src2l_vals[0]) ; j++) { |
| 40596 | long source2_l = src2l_vals[j]; |
| 40597 | |
| 40598 | int expected_result; |
| 40599 | int result; |
| 40600 | |
| 40601 | if (source2_l == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip175;} |
| 40602 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 40603 | |
| 40604 | expected_result = (int) (source1_i / source2_l); |
| 40605 | |
| 40606 | result = proc(source1_i, source2_l); |
| 40607 | if (expected_result != result) { |
| 40608 | printf("Failed int / long test, expected %d, got %d, for %d / %ld\n", |
| 40609 | expected_result, result, source1_i, source2_l); |
| 40610 | if (dumped == 0) cod_dump(gen_code); |
| 40611 | failed++; |
| 40612 | dumped++; |
| 40613 | } |
| 40614 | skip175: ; |
| 40615 | } |
| 40616 | } |
| 40617 | if (verbose) printf(" done\n"); |
| 40618 | cod_free_parse_context(context); |
| 40619 | cod_code_free(gen_code); |
| 40620 | } |
| 40621 | if ((only_run_test == NULL((void*)0)) || |
| 40622 | (strcmp(only_run_test, "i/f") == 0)) { |
| 40623 | int i, j; |
| 40624 | static char code[] = "{\n\ |
| 40625 | int a = p1;\n\ |
| 40626 | float b = p2;\n\ |
| 40627 | return a / b;\n\ |
| 40628 | }"; |
| 40629 | |
| 40630 | int (*proc)(int a, float b); |
| 40631 | cod_parse_context context = new_cod_parse_context(); |
| 40632 | int dumped = 0; |
| 40633 | |
| 40634 | cod_code gen_code; |
| 40635 | |
| 40636 | /* test for int / float */ |
| 40637 | if (verbose) printf("test for int / float"); |
| 40638 | |
| 40639 | cod_assoc_externs(context, externs); |
| 40640 | cod_parse_for_context(extern_string, context); |
| 40641 | |
| 40642 | cod_subroutine_declaration("int proc(int p1, float p2)", |
| 40643 | context); |
| 40644 | gen_code = cod_code_gen(code, context); |
| 40645 | proc = (int (*)(int, float))(long)gen_code->func; |
| 40646 | |
| 40647 | |
| 40648 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 40649 | int source1_i = src1i_vals[i]; |
| 40650 | for (j=0 ; j < sizeof(src2f_vals)/sizeof(src2f_vals[0]) ; j++) { |
| 40651 | float source2_f = src2f_vals[j]; |
| 40652 | double range = 0.000001 * (fabs((double)source1_i / (double)source2_f)); |
| 40653 | int expected_result; |
| 40654 | int result; |
| 40655 | |
| 40656 | if (source2_f == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip176;} |
| 40657 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 40658 | |
| 40659 | expected_result = (int) (source1_i / source2_f); |
| 40660 | |
| 40661 | result = proc(source1_i, source2_f); |
| 40662 | range += 1.0; |
| 40663 | if ((result > (expected_result + range)) || (result < (expected_result - range))) { |
| 40664 | printf("Failed int / float test, expected %d, got %d, for %d / %g\n", |
| 40665 | expected_result, result, source1_i, source2_f); |
| 40666 | if (dumped == 0) cod_dump(gen_code); |
| 40667 | failed++; |
| 40668 | dumped++; |
| 40669 | } |
| 40670 | skip176: ; |
| 40671 | } |
| 40672 | } |
| 40673 | if (verbose) printf(" done\n"); |
| 40674 | cod_free_parse_context(context); |
| 40675 | cod_code_free(gen_code); |
| 40676 | } |
| 40677 | if ((only_run_test == NULL((void*)0)) || |
| 40678 | (strcmp(only_run_test, "i/d") == 0)) { |
| 40679 | int i, j; |
| 40680 | static char code[] = "{\n\ |
| 40681 | int a = p1;\n\ |
| 40682 | double b = p2;\n\ |
| 40683 | return a / b;\n\ |
| 40684 | }"; |
| 40685 | |
| 40686 | int (*proc)(int a, double b); |
| 40687 | cod_parse_context context = new_cod_parse_context(); |
| 40688 | int dumped = 0; |
| 40689 | |
| 40690 | cod_code gen_code; |
| 40691 | |
| 40692 | /* test for int / double */ |
| 40693 | if (verbose) printf("test for int / double"); |
| 40694 | |
| 40695 | cod_assoc_externs(context, externs); |
| 40696 | cod_parse_for_context(extern_string, context); |
| 40697 | |
| 40698 | cod_subroutine_declaration("int proc(int p1, double p2)", |
| 40699 | context); |
| 40700 | gen_code = cod_code_gen(code, context); |
| 40701 | proc = (int (*)(int, double))(long)gen_code->func; |
| 40702 | |
| 40703 | |
| 40704 | for (i=0 ; i < sizeof(src1i_vals)/sizeof(src1i_vals[0]) ; i++) { |
| 40705 | int source1_i = src1i_vals[i]; |
| 40706 | for (j=0 ; j < sizeof(src2d_vals)/sizeof(src2d_vals[0]) ; j++) { |
| 40707 | double source2_d = src2d_vals[j]; |
| 40708 | |
| 40709 | int expected_result; |
| 40710 | int result; |
| 40711 | |
| 40712 | if (source2_d == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip177;} |
| 40713 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 40714 | |
| 40715 | expected_result = (int) (source1_i / source2_d); |
| 40716 | |
| 40717 | result = proc(source1_i, source2_d); |
| 40718 | if (expected_result != result) { |
| 40719 | printf("Failed int / double test, expected %d, got %d, for %d / %g\n", |
| 40720 | expected_result, result, source1_i, source2_d); |
| 40721 | if (dumped == 0) cod_dump(gen_code); |
| 40722 | failed++; |
| 40723 | dumped++; |
| 40724 | } |
| 40725 | skip177: ; |
| 40726 | } |
| 40727 | } |
| 40728 | if (verbose) printf(" done\n"); |
| 40729 | cod_free_parse_context(context); |
| 40730 | cod_code_free(gen_code); |
| 40731 | } |
| 40732 | } |
| 40733 | void div_u_tests() |
| 40734 | { |
| 40735 | if ((only_run_test == NULL((void*)0)) || |
| 40736 | (strcmp(only_run_test, "u/c") == 0)) { |
| 40737 | int i, j; |
| 40738 | static char code[] = "{\n\ |
| 40739 | unsigned int a = p1;\n\ |
| 40740 | signed char b = p2;\n\ |
| 40741 | return a / b;\n\ |
| 40742 | }"; |
| 40743 | |
| 40744 | unsigned int (*proc)(unsigned int a, signed char b); |
| 40745 | cod_parse_context context = new_cod_parse_context(); |
| 40746 | int dumped = 0; |
| 40747 | |
| 40748 | cod_code gen_code; |
| 40749 | |
| 40750 | /* test for unsigned int / signed char */ |
| 40751 | if (verbose) printf("test for unsigned int / signed char"); |
| 40752 | |
| 40753 | cod_assoc_externs(context, externs); |
| 40754 | cod_parse_for_context(extern_string, context); |
| 40755 | |
| 40756 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, signed char p2)", |
| 40757 | context); |
| 40758 | gen_code = cod_code_gen(code, context); |
| 40759 | proc = (unsigned int (*)(unsigned int, signed char))(long)gen_code->func; |
| 40760 | |
| 40761 | |
| 40762 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 40763 | unsigned int source1_u = src1u_vals[i]; |
| 40764 | for (j=0 ; j < sizeof(src2c_vals)/sizeof(src2c_vals[0]) ; j++) { |
| 40765 | signed char source2_c = src2c_vals[j]; |
| 40766 | |
| 40767 | unsigned int expected_result; |
| 40768 | unsigned int result; |
| 40769 | |
| 40770 | if (source2_c == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip178;} |
| 40771 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 40772 | |
| 40773 | expected_result = (unsigned int) (source1_u / source2_c); |
| 40774 | |
| 40775 | result = proc(source1_u, source2_c); |
| 40776 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 40777 | if (expected_result != result) { |
| 40778 | printf("Failed unsigned int / signed char test, expected %u, got %u, for %u / %d\n", |
| 40779 | expected_result, result, source1_u, source2_c); |
| 40780 | if (dumped == 0) cod_dump(gen_code); |
| 40781 | failed++; |
| 40782 | dumped++; |
| 40783 | } |
| 40784 | skip178: ; |
| 40785 | } |
| 40786 | } |
| 40787 | if (verbose) printf(" done\n"); |
| 40788 | cod_free_parse_context(context); |
| 40789 | cod_code_free(gen_code); |
| 40790 | } |
| 40791 | if ((only_run_test == NULL((void*)0)) || |
| 40792 | (strcmp(only_run_test, "u/uc") == 0)) { |
| 40793 | int i, j; |
| 40794 | static char code[] = "{\n\ |
| 40795 | unsigned int a = p1;\n\ |
| 40796 | unsigned char b = p2;\n\ |
| 40797 | return a / b;\n\ |
| 40798 | }"; |
| 40799 | |
| 40800 | unsigned int (*proc)(unsigned int a, unsigned char b); |
| 40801 | cod_parse_context context = new_cod_parse_context(); |
| 40802 | int dumped = 0; |
| 40803 | |
| 40804 | cod_code gen_code; |
| 40805 | |
| 40806 | /* test for unsigned int / unsigned char */ |
| 40807 | if (verbose) printf("test for unsigned int / unsigned char"); |
| 40808 | |
| 40809 | cod_assoc_externs(context, externs); |
| 40810 | cod_parse_for_context(extern_string, context); |
| 40811 | |
| 40812 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, unsigned char p2)", |
| 40813 | context); |
| 40814 | gen_code = cod_code_gen(code, context); |
| 40815 | proc = (unsigned int (*)(unsigned int, unsigned char))(long)gen_code->func; |
| 40816 | |
| 40817 | |
| 40818 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 40819 | unsigned int source1_u = src1u_vals[i]; |
| 40820 | for (j=0 ; j < sizeof(src2uc_vals)/sizeof(src2uc_vals[0]) ; j++) { |
| 40821 | unsigned char source2_uc = src2uc_vals[j]; |
| 40822 | |
| 40823 | unsigned int expected_result; |
| 40824 | unsigned int result; |
| 40825 | |
| 40826 | if (source2_uc == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip179;} |
| 40827 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 40828 | |
| 40829 | expected_result = (unsigned int) (source1_u / source2_uc); |
| 40830 | |
| 40831 | result = proc(source1_u, source2_uc); |
| 40832 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 40833 | if (expected_result != result) { |
| 40834 | printf("Failed unsigned int / unsigned char test, expected %u, got %u, for %u / %u\n", |
| 40835 | expected_result, result, source1_u, source2_uc); |
| 40836 | if (dumped == 0) cod_dump(gen_code); |
| 40837 | failed++; |
| 40838 | dumped++; |
| 40839 | } |
| 40840 | skip179: ; |
| 40841 | } |
| 40842 | } |
| 40843 | if (verbose) printf(" done\n"); |
| 40844 | cod_free_parse_context(context); |
| 40845 | cod_code_free(gen_code); |
| 40846 | } |
| 40847 | if ((only_run_test == NULL((void*)0)) || |
| 40848 | (strcmp(only_run_test, "u/s") == 0)) { |
| 40849 | int i, j; |
| 40850 | static char code[] = "{\n\ |
| 40851 | unsigned int a = p1;\n\ |
| 40852 | short b = p2;\n\ |
| 40853 | return a / b;\n\ |
| 40854 | }"; |
| 40855 | |
| 40856 | unsigned int (*proc)(unsigned int a, short b); |
| 40857 | cod_parse_context context = new_cod_parse_context(); |
| 40858 | int dumped = 0; |
| 40859 | |
| 40860 | cod_code gen_code; |
| 40861 | |
| 40862 | /* test for unsigned int / short */ |
| 40863 | if (verbose) printf("test for unsigned int / short"); |
| 40864 | |
| 40865 | cod_assoc_externs(context, externs); |
| 40866 | cod_parse_for_context(extern_string, context); |
| 40867 | |
| 40868 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, short p2)", |
| 40869 | context); |
| 40870 | gen_code = cod_code_gen(code, context); |
| 40871 | proc = (unsigned int (*)(unsigned int, short))(long)gen_code->func; |
| 40872 | |
| 40873 | |
| 40874 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 40875 | unsigned int source1_u = src1u_vals[i]; |
| 40876 | for (j=0 ; j < sizeof(src2s_vals)/sizeof(src2s_vals[0]) ; j++) { |
| 40877 | short source2_s = src2s_vals[j]; |
| 40878 | |
| 40879 | unsigned int expected_result; |
| 40880 | unsigned int result; |
| 40881 | |
| 40882 | if (source2_s == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip180;} |
| 40883 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 40884 | |
| 40885 | expected_result = (unsigned int) (source1_u / source2_s); |
| 40886 | |
| 40887 | result = proc(source1_u, source2_s); |
| 40888 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 40889 | if (expected_result != result) { |
| 40890 | printf("Failed unsigned int / short test, expected %u, got %u, for %u / %d\n", |
| 40891 | expected_result, result, source1_u, source2_s); |
| 40892 | if (dumped == 0) cod_dump(gen_code); |
| 40893 | failed++; |
| 40894 | dumped++; |
| 40895 | } |
| 40896 | skip180: ; |
| 40897 | } |
| 40898 | } |
| 40899 | if (verbose) printf(" done\n"); |
| 40900 | cod_free_parse_context(context); |
| 40901 | cod_code_free(gen_code); |
| 40902 | } |
| 40903 | if ((only_run_test == NULL((void*)0)) || |
| 40904 | (strcmp(only_run_test, "u/us") == 0)) { |
| 40905 | int i, j; |
| 40906 | static char code[] = "{\n\ |
| 40907 | unsigned int a = p1;\n\ |
| 40908 | unsigned short b = p2;\n\ |
| 40909 | return a / b;\n\ |
| 40910 | }"; |
| 40911 | |
| 40912 | unsigned int (*proc)(unsigned int a, unsigned short b); |
| 40913 | cod_parse_context context = new_cod_parse_context(); |
| 40914 | int dumped = 0; |
| 40915 | |
| 40916 | cod_code gen_code; |
| 40917 | |
| 40918 | /* test for unsigned int / unsigned short */ |
| 40919 | if (verbose) printf("test for unsigned int / unsigned short"); |
| 40920 | |
| 40921 | cod_assoc_externs(context, externs); |
| 40922 | cod_parse_for_context(extern_string, context); |
| 40923 | |
| 40924 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, unsigned short p2)", |
| 40925 | context); |
| 40926 | gen_code = cod_code_gen(code, context); |
| 40927 | proc = (unsigned int (*)(unsigned int, unsigned short))(long)gen_code->func; |
| 40928 | |
| 40929 | |
| 40930 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 40931 | unsigned int source1_u = src1u_vals[i]; |
| 40932 | for (j=0 ; j < sizeof(src2us_vals)/sizeof(src2us_vals[0]) ; j++) { |
| 40933 | unsigned short source2_us = src2us_vals[j]; |
| 40934 | |
| 40935 | unsigned int expected_result; |
| 40936 | unsigned int result; |
| 40937 | |
| 40938 | if (source2_us == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip181;} |
| 40939 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 40940 | |
| 40941 | expected_result = (unsigned int) (source1_u / source2_us); |
| 40942 | |
| 40943 | result = proc(source1_u, source2_us); |
| 40944 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 40945 | if (expected_result != result) { |
| 40946 | printf("Failed unsigned int / unsigned short test, expected %u, got %u, for %u / %u\n", |
| 40947 | expected_result, result, source1_u, source2_us); |
| 40948 | if (dumped == 0) cod_dump(gen_code); |
| 40949 | failed++; |
| 40950 | dumped++; |
| 40951 | } |
| 40952 | skip181: ; |
| 40953 | } |
| 40954 | } |
| 40955 | if (verbose) printf(" done\n"); |
| 40956 | cod_free_parse_context(context); |
| 40957 | cod_code_free(gen_code); |
| 40958 | } |
| 40959 | if ((only_run_test == NULL((void*)0)) || |
| 40960 | (strcmp(only_run_test, "u/i") == 0)) { |
| 40961 | int i, j; |
| 40962 | static char code[] = "{\n\ |
| 40963 | unsigned int a = p1;\n\ |
| 40964 | int b = p2;\n\ |
| 40965 | return a / b;\n\ |
| 40966 | }"; |
| 40967 | |
| 40968 | unsigned int (*proc)(unsigned int a, int b); |
| 40969 | cod_parse_context context = new_cod_parse_context(); |
| 40970 | int dumped = 0; |
| 40971 | |
| 40972 | cod_code gen_code; |
| 40973 | |
| 40974 | /* test for unsigned int / int */ |
| 40975 | if (verbose) printf("test for unsigned int / int"); |
| 40976 | |
| 40977 | cod_assoc_externs(context, externs); |
| 40978 | cod_parse_for_context(extern_string, context); |
| 40979 | |
| 40980 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, int p2)", |
| 40981 | context); |
| 40982 | gen_code = cod_code_gen(code, context); |
| 40983 | proc = (unsigned int (*)(unsigned int, int))(long)gen_code->func; |
| 40984 | |
| 40985 | |
| 40986 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 40987 | unsigned int source1_u = src1u_vals[i]; |
| 40988 | for (j=0 ; j < sizeof(src2i_vals)/sizeof(src2i_vals[0]) ; j++) { |
| 40989 | int source2_i = src2i_vals[j]; |
| 40990 | |
| 40991 | unsigned int expected_result; |
| 40992 | unsigned int result; |
| 40993 | |
| 40994 | if (source2_i == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip182;} |
| 40995 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 40996 | |
| 40997 | expected_result = (unsigned int) (source1_u / source2_i); |
| 40998 | |
| 40999 | result = proc(source1_u, source2_i); |
| 41000 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 41001 | if (expected_result != result) { |
| 41002 | printf("Failed unsigned int / int test, expected %u, got %u, for %u / %d\n", |
| 41003 | expected_result, result, source1_u, source2_i); |
| 41004 | if (dumped == 0) cod_dump(gen_code); |
| 41005 | failed++; |
| 41006 | dumped++; |
| 41007 | } |
| 41008 | skip182: ; |
| 41009 | } |
| 41010 | } |
| 41011 | if (verbose) printf(" done\n"); |
| 41012 | cod_free_parse_context(context); |
| 41013 | cod_code_free(gen_code); |
| 41014 | } |
| 41015 | if ((only_run_test == NULL((void*)0)) || |
| 41016 | (strcmp(only_run_test, "u/u") == 0)) { |
| 41017 | int i, j; |
| 41018 | static char code[] = "{\n\ |
| 41019 | unsigned int a = p1;\n\ |
| 41020 | unsigned int b = p2;\n\ |
| 41021 | return a / b;\n\ |
| 41022 | }"; |
| 41023 | |
| 41024 | unsigned int (*proc)(unsigned int a, unsigned int b); |
| 41025 | cod_parse_context context = new_cod_parse_context(); |
| 41026 | int dumped = 0; |
| 41027 | |
| 41028 | cod_code gen_code; |
| 41029 | |
| 41030 | /* test for unsigned int / unsigned int */ |
| 41031 | if (verbose) printf("test for unsigned int / unsigned int"); |
| 41032 | |
| 41033 | cod_assoc_externs(context, externs); |
| 41034 | cod_parse_for_context(extern_string, context); |
| 41035 | |
| 41036 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, unsigned int p2)", |
| 41037 | context); |
| 41038 | gen_code = cod_code_gen(code, context); |
| 41039 | proc = (unsigned int (*)(unsigned int, unsigned int))(long)gen_code->func; |
| 41040 | |
| 41041 | |
| 41042 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 41043 | unsigned int source1_u = src1u_vals[i]; |
| 41044 | for (j=0 ; j < sizeof(src2u_vals)/sizeof(src2u_vals[0]) ; j++) { |
| 41045 | unsigned int source2_u = src2u_vals[j]; |
| 41046 | |
| 41047 | unsigned int expected_result; |
| 41048 | unsigned int result; |
| 41049 | |
| 41050 | if (source2_u == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip183;} |
| 41051 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 41052 | |
| 41053 | expected_result = (unsigned int) (source1_u / source2_u); |
| 41054 | |
| 41055 | result = proc(source1_u, source2_u); |
| 41056 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 41057 | if (expected_result != result) { |
| 41058 | printf("Failed unsigned int / unsigned int test, expected %u, got %u, for %u / %u\n", |
| 41059 | expected_result, result, source1_u, source2_u); |
| 41060 | if (dumped == 0) cod_dump(gen_code); |
| 41061 | failed++; |
| 41062 | dumped++; |
| 41063 | } |
| 41064 | skip183: ; |
| 41065 | } |
| 41066 | } |
| 41067 | if (verbose) printf(" done\n"); |
| 41068 | cod_free_parse_context(context); |
| 41069 | cod_code_free(gen_code); |
| 41070 | } |
| 41071 | if ((only_run_test == NULL((void*)0)) || |
| 41072 | (strcmp(only_run_test, "u/ul") == 0)) { |
| 41073 | int i, j; |
| 41074 | static char code[] = "{\n\ |
| 41075 | unsigned int a = p1;\n\ |
| 41076 | unsigned long b = p2;\n\ |
| 41077 | return a / b;\n\ |
| 41078 | }"; |
| 41079 | |
| 41080 | unsigned int (*proc)(unsigned int a, unsigned long b); |
| 41081 | cod_parse_context context = new_cod_parse_context(); |
| 41082 | int dumped = 0; |
| 41083 | |
| 41084 | cod_code gen_code; |
| 41085 | |
| 41086 | /* test for unsigned int / unsigned long */ |
| 41087 | if (verbose) printf("test for unsigned int / unsigned long"); |
| 41088 | |
| 41089 | cod_assoc_externs(context, externs); |
| 41090 | cod_parse_for_context(extern_string, context); |
| 41091 | |
| 41092 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, unsigned long p2)", |
| 41093 | context); |
| 41094 | gen_code = cod_code_gen(code, context); |
| 41095 | proc = (unsigned int (*)(unsigned int, unsigned long))(long)gen_code->func; |
| 41096 | |
| 41097 | |
| 41098 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 41099 | unsigned int source1_u = src1u_vals[i]; |
| 41100 | for (j=0 ; j < sizeof(src2ul_vals)/sizeof(src2ul_vals[0]) ; j++) { |
| 41101 | unsigned long source2_ul = src2ul_vals[j]; |
| 41102 | |
| 41103 | unsigned int expected_result; |
| 41104 | unsigned int result; |
| 41105 | |
| 41106 | if (source2_ul == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip184;} |
| 41107 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 41108 | |
| 41109 | expected_result = (unsigned int) (source1_u / source2_ul); |
| 41110 | |
| 41111 | result = proc(source1_u, source2_ul); |
| 41112 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 41113 | if (expected_result != result) { |
| 41114 | printf("Failed unsigned int / unsigned long test, expected %u, got %u, for %u / %lu\n", |
| 41115 | expected_result, result, source1_u, source2_ul); |
| 41116 | if (dumped == 0) cod_dump(gen_code); |
| 41117 | failed++; |
| 41118 | dumped++; |
| 41119 | } |
| 41120 | skip184: ; |
| 41121 | } |
| 41122 | } |
| 41123 | if (verbose) printf(" done\n"); |
| 41124 | cod_free_parse_context(context); |
| 41125 | cod_code_free(gen_code); |
| 41126 | } |
| 41127 | if ((only_run_test == NULL((void*)0)) || |
| 41128 | (strcmp(only_run_test, "u/l") == 0)) { |
| 41129 | int i, j; |
| 41130 | static char code[] = "{\n\ |
| 41131 | unsigned int a = p1;\n\ |
| 41132 | long b = p2;\n\ |
| 41133 | return a / b;\n\ |
| 41134 | }"; |
| 41135 | |
| 41136 | unsigned int (*proc)(unsigned int a, long b); |
| 41137 | cod_parse_context context = new_cod_parse_context(); |
| 41138 | int dumped = 0; |
| 41139 | |
| 41140 | cod_code gen_code; |
| 41141 | |
| 41142 | /* test for unsigned int / long */ |
| 41143 | if (verbose) printf("test for unsigned int / long"); |
| 41144 | |
| 41145 | cod_assoc_externs(context, externs); |
| 41146 | cod_parse_for_context(extern_string, context); |
| 41147 | |
| 41148 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, long p2)", |
| 41149 | context); |
| 41150 | gen_code = cod_code_gen(code, context); |
| 41151 | proc = (unsigned int (*)(unsigned int, long))(long)gen_code->func; |
| 41152 | |
| 41153 | |
| 41154 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 41155 | unsigned int source1_u = src1u_vals[i]; |
| 41156 | for (j=0 ; j < sizeof(src2l_vals)/sizeof(src2l_vals[0]) ; j++) { |
| 41157 | long source2_l = src2l_vals[j]; |
| 41158 | |
| 41159 | unsigned int expected_result; |
| 41160 | unsigned int result; |
| 41161 | |
| 41162 | if (source2_l == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip185;} |
| 41163 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 41164 | |
| 41165 | expected_result = (unsigned int) (source1_u / source2_l); |
| 41166 | |
| 41167 | result = proc(source1_u, source2_l); |
| 41168 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 41169 | if (expected_result != result) { |
| 41170 | printf("Failed unsigned int / long test, expected %u, got %u, for %u / %ld\n", |
| 41171 | expected_result, result, source1_u, source2_l); |
| 41172 | if (dumped == 0) cod_dump(gen_code); |
| 41173 | failed++; |
| 41174 | dumped++; |
| 41175 | } |
| 41176 | skip185: ; |
| 41177 | } |
| 41178 | } |
| 41179 | if (verbose) printf(" done\n"); |
| 41180 | cod_free_parse_context(context); |
| 41181 | cod_code_free(gen_code); |
| 41182 | } |
| 41183 | if ((only_run_test == NULL((void*)0)) || |
| 41184 | (strcmp(only_run_test, "u/f") == 0)) { |
| 41185 | int i, j; |
| 41186 | static char code[] = "{\n\ |
| 41187 | unsigned int a = p1;\n\ |
| 41188 | float b = p2;\n\ |
| 41189 | return a / b;\n\ |
| 41190 | }"; |
| 41191 | |
| 41192 | unsigned int (*proc)(unsigned int a, float b); |
| 41193 | cod_parse_context context = new_cod_parse_context(); |
| 41194 | int dumped = 0; |
| 41195 | |
| 41196 | cod_code gen_code; |
| 41197 | |
| 41198 | /* test for unsigned int / float */ |
| 41199 | if (verbose) printf("test for unsigned int / float"); |
| 41200 | |
| 41201 | cod_assoc_externs(context, externs); |
| 41202 | cod_parse_for_context(extern_string, context); |
| 41203 | |
| 41204 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, float p2)", |
| 41205 | context); |
| 41206 | gen_code = cod_code_gen(code, context); |
| 41207 | proc = (unsigned int (*)(unsigned int, float))(long)gen_code->func; |
| 41208 | |
| 41209 | |
| 41210 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 41211 | unsigned int source1_u = src1u_vals[i]; |
| 41212 | for (j=0 ; j < sizeof(src2f_vals)/sizeof(src2f_vals[0]) ; j++) { |
| 41213 | float source2_f = src2f_vals[j]; |
| 41214 | double range = 0.000001 * (fabs((double)source1_u / (double)source2_f)); |
| 41215 | unsigned int expected_result; |
| 41216 | unsigned int result; |
| 41217 | |
| 41218 | if (source2_f == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip186;} |
| 41219 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 41220 | |
| 41221 | expected_result = (unsigned int) (source1_u / source2_f); |
| 41222 | |
| 41223 | result = proc(source1_u, source2_f); |
| 41224 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 41225 | range += 1.0; |
| 41226 | if ((result > (expected_result + range)) || (result < (expected_result - range))) { |
| 41227 | printf("Failed unsigned int / float test, expected %u, got %u, for %u / %g\n", |
| 41228 | expected_result, result, source1_u, source2_f); |
| 41229 | if (dumped == 0) cod_dump(gen_code); |
| 41230 | failed++; |
| 41231 | dumped++; |
| 41232 | } |
| 41233 | skip186: ; |
| 41234 | } |
| 41235 | } |
| 41236 | if (verbose) printf(" done\n"); |
| 41237 | cod_free_parse_context(context); |
| 41238 | cod_code_free(gen_code); |
| 41239 | } |
| 41240 | if ((only_run_test == NULL((void*)0)) || |
| 41241 | (strcmp(only_run_test, "u/d") == 0)) { |
| 41242 | int i, j; |
| 41243 | static char code[] = "{\n\ |
| 41244 | unsigned int a = p1;\n\ |
| 41245 | double b = p2;\n\ |
| 41246 | return a / b;\n\ |
| 41247 | }"; |
| 41248 | |
| 41249 | unsigned int (*proc)(unsigned int a, double b); |
| 41250 | cod_parse_context context = new_cod_parse_context(); |
| 41251 | int dumped = 0; |
| 41252 | |
| 41253 | cod_code gen_code; |
| 41254 | |
| 41255 | /* test for unsigned int / double */ |
| 41256 | if (verbose) printf("test for unsigned int / double"); |
| 41257 | |
| 41258 | cod_assoc_externs(context, externs); |
| 41259 | cod_parse_for_context(extern_string, context); |
| 41260 | |
| 41261 | cod_subroutine_declaration("unsigned int proc(unsigned int p1, double p2)", |
| 41262 | context); |
| 41263 | gen_code = cod_code_gen(code, context); |
| 41264 | proc = (unsigned int (*)(unsigned int, double))(long)gen_code->func; |
| 41265 | |
| 41266 | |
| 41267 | for (i=0 ; i < sizeof(src1u_vals)/sizeof(src1u_vals[0]) ; i++) { |
| 41268 | unsigned int source1_u = src1u_vals[i]; |
| 41269 | for (j=0 ; j < sizeof(src2d_vals)/sizeof(src2d_vals[0]) ; j++) { |
| 41270 | double source2_d = src2d_vals[j]; |
| 41271 | |
| 41272 | unsigned int expected_result; |
| 41273 | unsigned int result; |
| 41274 | |
| 41275 | if (source2_d == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip187;} |
| 41276 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 41277 | |
| 41278 | expected_result = (unsigned int) (source1_u / source2_d); |
| 41279 | |
| 41280 | result = proc(source1_u, source2_d); |
| 41281 | if ((expected_result == 0) || (expected_result == (unsigned int) 0xffffffff) || (expected_result == (unsigned int) 0x80000000)) continue; |
| 41282 | if (expected_result != result) { |
| 41283 | printf("Failed unsigned int / double test, expected %u, got %u, for %u / %g\n", |
| 41284 | expected_result, result, source1_u, source2_d); |
| 41285 | if (dumped == 0) cod_dump(gen_code); |
| 41286 | failed++; |
| 41287 | dumped++; |
| 41288 | } |
| 41289 | skip187: ; |
| 41290 | } |
| 41291 | } |
| 41292 | if (verbose) printf(" done\n"); |
| 41293 | cod_free_parse_context(context); |
| 41294 | cod_code_free(gen_code); |
| 41295 | } |
| 41296 | } |
| 41297 | void div_ul_tests() |
| 41298 | { |
| 41299 | if ((only_run_test == NULL((void*)0)) || |
| 41300 | (strcmp(only_run_test, "ul/c") == 0)) { |
| 41301 | int i, j; |
| 41302 | static char code[] = "{\n\ |
| 41303 | unsigned long a = p1;\n\ |
| 41304 | signed char b = p2;\n\ |
| 41305 | return a / b;\n\ |
| 41306 | }"; |
| 41307 | |
| 41308 | unsigned long (*proc)(unsigned long a, signed char b); |
| 41309 | cod_parse_context context = new_cod_parse_context(); |
| 41310 | int dumped = 0; |
| 41311 | |
| 41312 | cod_code gen_code; |
| 41313 | |
| 41314 | /* test for unsigned long / signed char */ |
| 41315 | if (verbose) printf("test for unsigned long / signed char"); |
| 41316 | |
| 41317 | cod_assoc_externs(context, externs); |
| 41318 | cod_parse_for_context(extern_string, context); |
| 41319 | |
| 41320 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, signed char p2)", |
| 41321 | context); |
| 41322 | gen_code = cod_code_gen(code, context); |
| 41323 | proc = (unsigned long (*)(unsigned long, signed char))(long)gen_code->func; |
| 41324 | |
| 41325 | |
| 41326 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 41327 | unsigned long source1_ul = src1ul_vals[i]; |
| 41328 | for (j=0 ; j < sizeof(src2c_vals)/sizeof(src2c_vals[0]) ; j++) { |
| 41329 | signed char source2_c = src2c_vals[j]; |
| 41330 | |
| 41331 | unsigned long expected_result; |
| 41332 | unsigned long result; |
| 41333 | |
| 41334 | if (source2_c == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip188;} |
| 41335 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 41336 | |
| 41337 | expected_result = (unsigned long) (source1_ul / source2_c); |
| 41338 | |
| 41339 | result = proc(source1_ul, source2_c); |
| 41340 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 41341 | if (expected_result != result) { |
| 41342 | printf("Failed unsigned long / signed char test, expected %lu, got %lu, for %lu / %d\n", |
| 41343 | expected_result, result, source1_ul, source2_c); |
| 41344 | if (dumped == 0) cod_dump(gen_code); |
| 41345 | failed++; |
| 41346 | dumped++; |
| 41347 | } |
| 41348 | skip188: ; |
| 41349 | } |
| 41350 | } |
| 41351 | if (verbose) printf(" done\n"); |
| 41352 | cod_free_parse_context(context); |
| 41353 | cod_code_free(gen_code); |
| 41354 | } |
| 41355 | if ((only_run_test == NULL((void*)0)) || |
| 41356 | (strcmp(only_run_test, "ul/uc") == 0)) { |
| 41357 | int i, j; |
| 41358 | static char code[] = "{\n\ |
| 41359 | unsigned long a = p1;\n\ |
| 41360 | unsigned char b = p2;\n\ |
| 41361 | return a / b;\n\ |
| 41362 | }"; |
| 41363 | |
| 41364 | unsigned long (*proc)(unsigned long a, unsigned char b); |
| 41365 | cod_parse_context context = new_cod_parse_context(); |
| 41366 | int dumped = 0; |
| 41367 | |
| 41368 | cod_code gen_code; |
| 41369 | |
| 41370 | /* test for unsigned long / unsigned char */ |
| 41371 | if (verbose) printf("test for unsigned long / unsigned char"); |
| 41372 | |
| 41373 | cod_assoc_externs(context, externs); |
| 41374 | cod_parse_for_context(extern_string, context); |
| 41375 | |
| 41376 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, unsigned char p2)", |
| 41377 | context); |
| 41378 | gen_code = cod_code_gen(code, context); |
| 41379 | proc = (unsigned long (*)(unsigned long, unsigned char))(long)gen_code->func; |
| 41380 | |
| 41381 | |
| 41382 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 41383 | unsigned long source1_ul = src1ul_vals[i]; |
| 41384 | for (j=0 ; j < sizeof(src2uc_vals)/sizeof(src2uc_vals[0]) ; j++) { |
| 41385 | unsigned char source2_uc = src2uc_vals[j]; |
| 41386 | |
| 41387 | unsigned long expected_result; |
| 41388 | unsigned long result; |
| 41389 | |
| 41390 | if (source2_uc == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip189;} |
| 41391 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 41392 | |
| 41393 | expected_result = (unsigned long) (source1_ul / source2_uc); |
| 41394 | |
| 41395 | result = proc(source1_ul, source2_uc); |
| 41396 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 41397 | if (expected_result != result) { |
| 41398 | printf("Failed unsigned long / unsigned char test, expected %lu, got %lu, for %lu / %u\n", |
| 41399 | expected_result, result, source1_ul, source2_uc); |
| 41400 | if (dumped == 0) cod_dump(gen_code); |
| 41401 | failed++; |
| 41402 | dumped++; |
| 41403 | } |
| 41404 | skip189: ; |
| 41405 | } |
| 41406 | } |
| 41407 | if (verbose) printf(" done\n"); |
| 41408 | cod_free_parse_context(context); |
| 41409 | cod_code_free(gen_code); |
| 41410 | } |
| 41411 | if ((only_run_test == NULL((void*)0)) || |
| 41412 | (strcmp(only_run_test, "ul/s") == 0)) { |
| 41413 | int i, j; |
| 41414 | static char code[] = "{\n\ |
| 41415 | unsigned long a = p1;\n\ |
| 41416 | short b = p2;\n\ |
| 41417 | return a / b;\n\ |
| 41418 | }"; |
| 41419 | |
| 41420 | unsigned long (*proc)(unsigned long a, short b); |
| 41421 | cod_parse_context context = new_cod_parse_context(); |
| 41422 | int dumped = 0; |
| 41423 | |
| 41424 | cod_code gen_code; |
| 41425 | |
| 41426 | /* test for unsigned long / short */ |
| 41427 | if (verbose) printf("test for unsigned long / short"); |
| 41428 | |
| 41429 | cod_assoc_externs(context, externs); |
| 41430 | cod_parse_for_context(extern_string, context); |
| 41431 | |
| 41432 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, short p2)", |
| 41433 | context); |
| 41434 | gen_code = cod_code_gen(code, context); |
| 41435 | proc = (unsigned long (*)(unsigned long, short))(long)gen_code->func; |
| 41436 | |
| 41437 | |
| 41438 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 41439 | unsigned long source1_ul = src1ul_vals[i]; |
| 41440 | for (j=0 ; j < sizeof(src2s_vals)/sizeof(src2s_vals[0]) ; j++) { |
| 41441 | short source2_s = src2s_vals[j]; |
| 41442 | |
| 41443 | unsigned long expected_result; |
| 41444 | unsigned long result; |
| 41445 | |
| 41446 | if (source2_s == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip190;} |
| 41447 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 41448 | |
| 41449 | expected_result = (unsigned long) (source1_ul / source2_s); |
| 41450 | |
| 41451 | result = proc(source1_ul, source2_s); |
| 41452 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 41453 | if (expected_result != result) { |
| 41454 | printf("Failed unsigned long / short test, expected %lu, got %lu, for %lu / %d\n", |
| 41455 | expected_result, result, source1_ul, source2_s); |
| 41456 | if (dumped == 0) cod_dump(gen_code); |
| 41457 | failed++; |
| 41458 | dumped++; |
| 41459 | } |
| 41460 | skip190: ; |
| 41461 | } |
| 41462 | } |
| 41463 | if (verbose) printf(" done\n"); |
| 41464 | cod_free_parse_context(context); |
| 41465 | cod_code_free(gen_code); |
| 41466 | } |
| 41467 | if ((only_run_test == NULL((void*)0)) || |
| 41468 | (strcmp(only_run_test, "ul/us") == 0)) { |
| 41469 | int i, j; |
| 41470 | static char code[] = "{\n\ |
| 41471 | unsigned long a = p1;\n\ |
| 41472 | unsigned short b = p2;\n\ |
| 41473 | return a / b;\n\ |
| 41474 | }"; |
| 41475 | |
| 41476 | unsigned long (*proc)(unsigned long a, unsigned short b); |
| 41477 | cod_parse_context context = new_cod_parse_context(); |
| 41478 | int dumped = 0; |
| 41479 | |
| 41480 | cod_code gen_code; |
| 41481 | |
| 41482 | /* test for unsigned long / unsigned short */ |
| 41483 | if (verbose) printf("test for unsigned long / unsigned short"); |
| 41484 | |
| 41485 | cod_assoc_externs(context, externs); |
| 41486 | cod_parse_for_context(extern_string, context); |
| 41487 | |
| 41488 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, unsigned short p2)", |
| 41489 | context); |
| 41490 | gen_code = cod_code_gen(code, context); |
| 41491 | proc = (unsigned long (*)(unsigned long, unsigned short))(long)gen_code->func; |
| 41492 | |
| 41493 | |
| 41494 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 41495 | unsigned long source1_ul = src1ul_vals[i]; |
| 41496 | for (j=0 ; j < sizeof(src2us_vals)/sizeof(src2us_vals[0]) ; j++) { |
| 41497 | unsigned short source2_us = src2us_vals[j]; |
| 41498 | |
| 41499 | unsigned long expected_result; |
| 41500 | unsigned long result; |
| 41501 | |
| 41502 | if (source2_us == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip191;} |
| 41503 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 41504 | |
| 41505 | expected_result = (unsigned long) (source1_ul / source2_us); |
| 41506 | |
| 41507 | result = proc(source1_ul, source2_us); |
| 41508 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 41509 | if (expected_result != result) { |
| 41510 | printf("Failed unsigned long / unsigned short test, expected %lu, got %lu, for %lu / %u\n", |
| 41511 | expected_result, result, source1_ul, source2_us); |
| 41512 | if (dumped == 0) cod_dump(gen_code); |
| 41513 | failed++; |
| 41514 | dumped++; |
| 41515 | } |
| 41516 | skip191: ; |
| 41517 | } |
| 41518 | } |
| 41519 | if (verbose) printf(" done\n"); |
| 41520 | cod_free_parse_context(context); |
| 41521 | cod_code_free(gen_code); |
| 41522 | } |
| 41523 | if ((only_run_test == NULL((void*)0)) || |
| 41524 | (strcmp(only_run_test, "ul/i") == 0)) { |
| 41525 | int i, j; |
| 41526 | static char code[] = "{\n\ |
| 41527 | unsigned long a = p1;\n\ |
| 41528 | int b = p2;\n\ |
| 41529 | return a / b;\n\ |
| 41530 | }"; |
| 41531 | |
| 41532 | unsigned long (*proc)(unsigned long a, int b); |
| 41533 | cod_parse_context context = new_cod_parse_context(); |
| 41534 | int dumped = 0; |
| 41535 | |
| 41536 | cod_code gen_code; |
| 41537 | |
| 41538 | /* test for unsigned long / int */ |
| 41539 | if (verbose) printf("test for unsigned long / int"); |
| 41540 | |
| 41541 | cod_assoc_externs(context, externs); |
| 41542 | cod_parse_for_context(extern_string, context); |
| 41543 | |
| 41544 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, int p2)", |
| 41545 | context); |
| 41546 | gen_code = cod_code_gen(code, context); |
| 41547 | proc = (unsigned long (*)(unsigned long, int))(long)gen_code->func; |
| 41548 | |
| 41549 | |
| 41550 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 41551 | unsigned long source1_ul = src1ul_vals[i]; |
| 41552 | for (j=0 ; j < sizeof(src2i_vals)/sizeof(src2i_vals[0]) ; j++) { |
| 41553 | int source2_i = src2i_vals[j]; |
| 41554 | |
| 41555 | unsigned long expected_result; |
| 41556 | unsigned long result; |
| 41557 | |
| 41558 | if (source2_i == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip192;} |
| 41559 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 41560 | |
| 41561 | expected_result = (unsigned long) (source1_ul / source2_i); |
| 41562 | |
| 41563 | result = proc(source1_ul, source2_i); |
| 41564 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 41565 | if (expected_result != result) { |
| 41566 | printf("Failed unsigned long / int test, expected %lu, got %lu, for %lu / %d\n", |
| 41567 | expected_result, result, source1_ul, source2_i); |
| 41568 | if (dumped == 0) cod_dump(gen_code); |
| 41569 | failed++; |
| 41570 | dumped++; |
| 41571 | } |
| 41572 | skip192: ; |
| 41573 | } |
| 41574 | } |
| 41575 | if (verbose) printf(" done\n"); |
| 41576 | cod_free_parse_context(context); |
| 41577 | cod_code_free(gen_code); |
| 41578 | } |
| 41579 | if ((only_run_test == NULL((void*)0)) || |
| 41580 | (strcmp(only_run_test, "ul/u") == 0)) { |
| 41581 | int i, j; |
| 41582 | static char code[] = "{\n\ |
| 41583 | unsigned long a = p1;\n\ |
| 41584 | unsigned int b = p2;\n\ |
| 41585 | return a / b;\n\ |
| 41586 | }"; |
| 41587 | |
| 41588 | unsigned long (*proc)(unsigned long a, unsigned int b); |
| 41589 | cod_parse_context context = new_cod_parse_context(); |
| 41590 | int dumped = 0; |
| 41591 | |
| 41592 | cod_code gen_code; |
| 41593 | |
| 41594 | /* test for unsigned long / unsigned int */ |
| 41595 | if (verbose) printf("test for unsigned long / unsigned int"); |
| 41596 | |
| 41597 | cod_assoc_externs(context, externs); |
| 41598 | cod_parse_for_context(extern_string, context); |
| 41599 | |
| 41600 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, unsigned int p2)", |
| 41601 | context); |
| 41602 | gen_code = cod_code_gen(code, context); |
| 41603 | proc = (unsigned long (*)(unsigned long, unsigned int))(long)gen_code->func; |
| 41604 | |
| 41605 | |
| 41606 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 41607 | unsigned long source1_ul = src1ul_vals[i]; |
| 41608 | for (j=0 ; j < sizeof(src2u_vals)/sizeof(src2u_vals[0]) ; j++) { |
| 41609 | unsigned int source2_u = src2u_vals[j]; |
| 41610 | |
| 41611 | unsigned long expected_result; |
| 41612 | unsigned long result; |
| 41613 | |
| 41614 | if (source2_u == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip193;} |
| 41615 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 41616 | |
| 41617 | expected_result = (unsigned long) (source1_ul / source2_u); |
| 41618 | |
| 41619 | result = proc(source1_ul, source2_u); |
| 41620 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 41621 | if (expected_result != result) { |
| 41622 | printf("Failed unsigned long / unsigned int test, expected %lu, got %lu, for %lu / %u\n", |
| 41623 | expected_result, result, source1_ul, source2_u); |
| 41624 | if (dumped == 0) cod_dump(gen_code); |
| 41625 | failed++; |
| 41626 | dumped++; |
| 41627 | } |
| 41628 | skip193: ; |
| 41629 | } |
| 41630 | } |
| 41631 | if (verbose) printf(" done\n"); |
| 41632 | cod_free_parse_context(context); |
| 41633 | cod_code_free(gen_code); |
| 41634 | } |
| 41635 | if ((only_run_test == NULL((void*)0)) || |
| 41636 | (strcmp(only_run_test, "ul/ul") == 0)) { |
| 41637 | int i, j; |
| 41638 | static char code[] = "{\n\ |
| 41639 | unsigned long a = p1;\n\ |
| 41640 | unsigned long b = p2;\n\ |
| 41641 | return a / b;\n\ |
| 41642 | }"; |
| 41643 | |
| 41644 | unsigned long (*proc)(unsigned long a, unsigned long b); |
| 41645 | cod_parse_context context = new_cod_parse_context(); |
| 41646 | int dumped = 0; |
| 41647 | |
| 41648 | cod_code gen_code; |
| 41649 | |
| 41650 | /* test for unsigned long / unsigned long */ |
| 41651 | if (verbose) printf("test for unsigned long / unsigned long"); |
| 41652 | |
| 41653 | cod_assoc_externs(context, externs); |
| 41654 | cod_parse_for_context(extern_string, context); |
| 41655 | |
| 41656 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, unsigned long p2)", |
| 41657 | context); |
| 41658 | gen_code = cod_code_gen(code, context); |
| 41659 | proc = (unsigned long (*)(unsigned long, unsigned long))(long)gen_code->func; |
| 41660 | |
| 41661 | |
| 41662 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 41663 | unsigned long source1_ul = src1ul_vals[i]; |
| 41664 | for (j=0 ; j < sizeof(src2ul_vals)/sizeof(src2ul_vals[0]) ; j++) { |
| 41665 | unsigned long source2_ul = src2ul_vals[j]; |
| 41666 | |
| 41667 | unsigned long expected_result; |
| 41668 | unsigned long result; |
| 41669 | |
| 41670 | if (source2_ul == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip194;} |
| 41671 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 41672 | |
| 41673 | expected_result = (unsigned long) (source1_ul / source2_ul); |
| 41674 | |
| 41675 | result = proc(source1_ul, source2_ul); |
| 41676 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 41677 | if (expected_result != result) { |
| 41678 | printf("Failed unsigned long / unsigned long test, expected %lu, got %lu, for %lu / %lu\n", |
| 41679 | expected_result, result, source1_ul, source2_ul); |
| 41680 | if (dumped == 0) cod_dump(gen_code); |
| 41681 | failed++; |
| 41682 | dumped++; |
| 41683 | } |
| 41684 | skip194: ; |
| 41685 | } |
| 41686 | } |
| 41687 | if (verbose) printf(" done\n"); |
| 41688 | cod_free_parse_context(context); |
| 41689 | cod_code_free(gen_code); |
| 41690 | } |
| 41691 | if ((only_run_test == NULL((void*)0)) || |
| 41692 | (strcmp(only_run_test, "ul/l") == 0)) { |
| 41693 | int i, j; |
| 41694 | static char code[] = "{\n\ |
| 41695 | unsigned long a = p1;\n\ |
| 41696 | long b = p2;\n\ |
| 41697 | return a / b;\n\ |
| 41698 | }"; |
| 41699 | |
| 41700 | unsigned long (*proc)(unsigned long a, long b); |
| 41701 | cod_parse_context context = new_cod_parse_context(); |
| 41702 | int dumped = 0; |
| 41703 | |
| 41704 | cod_code gen_code; |
| 41705 | |
| 41706 | /* test for unsigned long / long */ |
| 41707 | if (verbose) printf("test for unsigned long / long"); |
| 41708 | |
| 41709 | cod_assoc_externs(context, externs); |
| 41710 | cod_parse_for_context(extern_string, context); |
| 41711 | |
| 41712 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, long p2)", |
| 41713 | context); |
| 41714 | gen_code = cod_code_gen(code, context); |
| 41715 | proc = (unsigned long (*)(unsigned long, long))(long)gen_code->func; |
| 41716 | |
| 41717 | |
| 41718 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 41719 | unsigned long source1_ul = src1ul_vals[i]; |
| 41720 | for (j=0 ; j < sizeof(src2l_vals)/sizeof(src2l_vals[0]) ; j++) { |
| 41721 | long source2_l = src2l_vals[j]; |
| 41722 | |
| 41723 | unsigned long expected_result; |
| 41724 | unsigned long result; |
| 41725 | |
| 41726 | if (source2_l == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip195;} |
| 41727 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 41728 | |
| 41729 | expected_result = (unsigned long) (source1_ul / source2_l); |
| 41730 | |
| 41731 | result = proc(source1_ul, source2_l); |
| 41732 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 41733 | if (expected_result != result) { |
| 41734 | printf("Failed unsigned long / long test, expected %lu, got %lu, for %lu / %ld\n", |
| 41735 | expected_result, result, source1_ul, source2_l); |
| 41736 | if (dumped == 0) cod_dump(gen_code); |
| 41737 | failed++; |
| 41738 | dumped++; |
| 41739 | } |
| 41740 | skip195: ; |
| 41741 | } |
| 41742 | } |
| 41743 | if (verbose) printf(" done\n"); |
| 41744 | cod_free_parse_context(context); |
| 41745 | cod_code_free(gen_code); |
| 41746 | } |
| 41747 | if ((only_run_test == NULL((void*)0)) || |
| 41748 | (strcmp(only_run_test, "ul/f") == 0)) { |
| 41749 | int i, j; |
| 41750 | static char code[] = "{\n\ |
| 41751 | unsigned long a = p1;\n\ |
| 41752 | float b = p2;\n\ |
| 41753 | return a / b;\n\ |
| 41754 | }"; |
| 41755 | |
| 41756 | unsigned long (*proc)(unsigned long a, float b); |
| 41757 | cod_parse_context context = new_cod_parse_context(); |
| 41758 | int dumped = 0; |
| 41759 | |
| 41760 | cod_code gen_code; |
| 41761 | |
| 41762 | /* test for unsigned long / float */ |
| 41763 | if (verbose) printf("test for unsigned long / float"); |
| 41764 | |
| 41765 | cod_assoc_externs(context, externs); |
| 41766 | cod_parse_for_context(extern_string, context); |
| 41767 | |
| 41768 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, float p2)", |
| 41769 | context); |
| 41770 | gen_code = cod_code_gen(code, context); |
| 41771 | proc = (unsigned long (*)(unsigned long, float))(long)gen_code->func; |
| 41772 | |
| 41773 | |
| 41774 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 41775 | unsigned long source1_ul = src1ul_vals[i]; |
| 41776 | for (j=0 ; j < sizeof(src2f_vals)/sizeof(src2f_vals[0]) ; j++) { |
| 41777 | float source2_f = src2f_vals[j]; |
| 41778 | double range = 0.000001 * (fabs((double)source1_ul / (double)source2_f)); |
| 41779 | unsigned long expected_result; |
| 41780 | unsigned long result; |
| 41781 | |
| 41782 | if (source2_f == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip196;} |
| 41783 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 41784 | |
| 41785 | expected_result = (unsigned long) (source1_ul / source2_f); |
| 41786 | |
| 41787 | result = proc(source1_ul, source2_f); |
| 41788 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 41789 | range += 1.0; |
| 41790 | if ((result > (expected_result + range)) || (result < (expected_result - range))) { |
| 41791 | printf("Failed unsigned long / float test, expected %lu, got %lu, for %lu / %g\n", |
| 41792 | expected_result, result, source1_ul, source2_f); |
| 41793 | if (dumped == 0) cod_dump(gen_code); |
| 41794 | failed++; |
| 41795 | dumped++; |
| 41796 | } |
| 41797 | skip196: ; |
| 41798 | } |
| 41799 | } |
| 41800 | if (verbose) printf(" done\n"); |
| 41801 | cod_free_parse_context(context); |
| 41802 | cod_code_free(gen_code); |
| 41803 | } |
| 41804 | if ((only_run_test == NULL((void*)0)) || |
| 41805 | (strcmp(only_run_test, "ul/d") == 0)) { |
| 41806 | int i, j; |
| 41807 | static char code[] = "{\n\ |
| 41808 | unsigned long a = p1;\n\ |
| 41809 | double b = p2;\n\ |
| 41810 | return a / b;\n\ |
| 41811 | }"; |
| 41812 | |
| 41813 | unsigned long (*proc)(unsigned long a, double b); |
| 41814 | cod_parse_context context = new_cod_parse_context(); |
| 41815 | int dumped = 0; |
| 41816 | |
| 41817 | cod_code gen_code; |
| 41818 | |
| 41819 | /* test for unsigned long / double */ |
| 41820 | if (verbose) printf("test for unsigned long / double"); |
| 41821 | |
| 41822 | cod_assoc_externs(context, externs); |
| 41823 | cod_parse_for_context(extern_string, context); |
| 41824 | |
| 41825 | cod_subroutine_declaration("unsigned long proc(unsigned long p1, double p2)", |
| 41826 | context); |
| 41827 | gen_code = cod_code_gen(code, context); |
| 41828 | proc = (unsigned long (*)(unsigned long, double))(long)gen_code->func; |
| 41829 | |
| 41830 | |
| 41831 | for (i=0 ; i < sizeof(src1ul_vals)/sizeof(src1ul_vals[0]) ; i++) { |
| 41832 | unsigned long source1_ul = src1ul_vals[i]; |
| 41833 | for (j=0 ; j < sizeof(src2d_vals)/sizeof(src2d_vals[0]) ; j++) { |
| 41834 | double source2_d = src2d_vals[j]; |
| 41835 | |
| 41836 | unsigned long expected_result; |
| 41837 | unsigned long result; |
| 41838 | |
| 41839 | if (source2_d == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip197;} |
| 41840 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 41841 | |
| 41842 | expected_result = (unsigned long) (source1_ul / source2_d); |
| 41843 | |
| 41844 | result = proc(source1_ul, source2_d); |
| 41845 | if ((expected_result == 0) || (expected_result == (unsigned long) 0xffffffffffffffff) || (expected_result == (unsigned long) 0x8000000000000000)) continue; |
| 41846 | if (expected_result != result) { |
| 41847 | printf("Failed unsigned long / double test, expected %lu, got %lu, for %lu / %g\n", |
| 41848 | expected_result, result, source1_ul, source2_d); |
| 41849 | if (dumped == 0) cod_dump(gen_code); |
| 41850 | failed++; |
| 41851 | dumped++; |
| 41852 | } |
| 41853 | skip197: ; |
| 41854 | } |
| 41855 | } |
| 41856 | if (verbose) printf(" done\n"); |
| 41857 | cod_free_parse_context(context); |
| 41858 | cod_code_free(gen_code); |
| 41859 | } |
| 41860 | } |
| 41861 | void div_l_tests() |
| 41862 | { |
| 41863 | if ((only_run_test == NULL((void*)0)) || |
| 41864 | (strcmp(only_run_test, "l/c") == 0)) { |
| 41865 | int i, j; |
| 41866 | static char code[] = "{\n\ |
| 41867 | long a = p1;\n\ |
| 41868 | signed char b = p2;\n\ |
| 41869 | return a / b;\n\ |
| 41870 | }"; |
| 41871 | |
| 41872 | long (*proc)(long a, signed char b); |
| 41873 | cod_parse_context context = new_cod_parse_context(); |
| 41874 | int dumped = 0; |
| 41875 | |
| 41876 | cod_code gen_code; |
| 41877 | |
| 41878 | /* test for long / signed char */ |
| 41879 | if (verbose) printf("test for long / signed char"); |
| 41880 | |
| 41881 | cod_assoc_externs(context, externs); |
| 41882 | cod_parse_for_context(extern_string, context); |
| 41883 | |
| 41884 | cod_subroutine_declaration("long proc(long p1, signed char p2)", |
| 41885 | context); |
| 41886 | gen_code = cod_code_gen(code, context); |
| 41887 | proc = (long (*)(long, signed char))(long)gen_code->func; |
| 41888 | |
| 41889 | |
| 41890 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 41891 | long source1_l = src1l_vals[i]; |
| 41892 | for (j=0 ; j < sizeof(src2c_vals)/sizeof(src2c_vals[0]) ; j++) { |
| 41893 | signed char source2_c = src2c_vals[j]; |
| 41894 | |
| 41895 | long expected_result; |
| 41896 | long result; |
| 41897 | |
| 41898 | if (source2_c == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip198;} |
| 41899 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 41900 | |
| 41901 | expected_result = (long) (source1_l / source2_c); |
| 41902 | |
| 41903 | result = proc(source1_l, source2_c); |
| 41904 | if (expected_result != result) { |
| 41905 | printf("Failed long / signed char test, expected %ld, got %ld, for %ld / %d\n", |
| 41906 | expected_result, result, source1_l, source2_c); |
| 41907 | if (dumped == 0) cod_dump(gen_code); |
| 41908 | failed++; |
| 41909 | dumped++; |
| 41910 | } |
| 41911 | skip198: ; |
| 41912 | } |
| 41913 | } |
| 41914 | if (verbose) printf(" done\n"); |
| 41915 | cod_free_parse_context(context); |
| 41916 | cod_code_free(gen_code); |
| 41917 | } |
| 41918 | if ((only_run_test == NULL((void*)0)) || |
| 41919 | (strcmp(only_run_test, "l/uc") == 0)) { |
| 41920 | int i, j; |
| 41921 | static char code[] = "{\n\ |
| 41922 | long a = p1;\n\ |
| 41923 | unsigned char b = p2;\n\ |
| 41924 | return a / b;\n\ |
| 41925 | }"; |
| 41926 | |
| 41927 | long (*proc)(long a, unsigned char b); |
| 41928 | cod_parse_context context = new_cod_parse_context(); |
| 41929 | int dumped = 0; |
| 41930 | |
| 41931 | cod_code gen_code; |
| 41932 | |
| 41933 | /* test for long / unsigned char */ |
| 41934 | if (verbose) printf("test for long / unsigned char"); |
| 41935 | |
| 41936 | cod_assoc_externs(context, externs); |
| 41937 | cod_parse_for_context(extern_string, context); |
| 41938 | |
| 41939 | cod_subroutine_declaration("long proc(long p1, unsigned char p2)", |
| 41940 | context); |
| 41941 | gen_code = cod_code_gen(code, context); |
| 41942 | proc = (long (*)(long, unsigned char))(long)gen_code->func; |
| 41943 | |
| 41944 | |
| 41945 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 41946 | long source1_l = src1l_vals[i]; |
| 41947 | for (j=0 ; j < sizeof(src2uc_vals)/sizeof(src2uc_vals[0]) ; j++) { |
| 41948 | unsigned char source2_uc = src2uc_vals[j]; |
| 41949 | |
| 41950 | long expected_result; |
| 41951 | long result; |
| 41952 | |
| 41953 | if (source2_uc == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip199;} |
| 41954 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 41955 | |
| 41956 | expected_result = (long) (source1_l / source2_uc); |
| 41957 | |
| 41958 | result = proc(source1_l, source2_uc); |
| 41959 | if (expected_result != result) { |
| 41960 | printf("Failed long / unsigned char test, expected %ld, got %ld, for %ld / %u\n", |
| 41961 | expected_result, result, source1_l, source2_uc); |
| 41962 | if (dumped == 0) cod_dump(gen_code); |
| 41963 | failed++; |
| 41964 | dumped++; |
| 41965 | } |
| 41966 | skip199: ; |
| 41967 | } |
| 41968 | } |
| 41969 | if (verbose) printf(" done\n"); |
| 41970 | cod_free_parse_context(context); |
| 41971 | cod_code_free(gen_code); |
| 41972 | } |
| 41973 | if ((only_run_test == NULL((void*)0)) || |
| 41974 | (strcmp(only_run_test, "l/s") == 0)) { |
| 41975 | int i, j; |
| 41976 | static char code[] = "{\n\ |
| 41977 | long a = p1;\n\ |
| 41978 | short b = p2;\n\ |
| 41979 | return a / b;\n\ |
| 41980 | }"; |
| 41981 | |
| 41982 | long (*proc)(long a, short b); |
| 41983 | cod_parse_context context = new_cod_parse_context(); |
| 41984 | int dumped = 0; |
| 41985 | |
| 41986 | cod_code gen_code; |
| 41987 | |
| 41988 | /* test for long / short */ |
| 41989 | if (verbose) printf("test for long / short"); |
| 41990 | |
| 41991 | cod_assoc_externs(context, externs); |
| 41992 | cod_parse_for_context(extern_string, context); |
| 41993 | |
| 41994 | cod_subroutine_declaration("long proc(long p1, short p2)", |
| 41995 | context); |
| 41996 | gen_code = cod_code_gen(code, context); |
| 41997 | proc = (long (*)(long, short))(long)gen_code->func; |
| 41998 | |
| 41999 | |
| 42000 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 42001 | long source1_l = src1l_vals[i]; |
| 42002 | for (j=0 ; j < sizeof(src2s_vals)/sizeof(src2s_vals[0]) ; j++) { |
| 42003 | short source2_s = src2s_vals[j]; |
| 42004 | |
| 42005 | long expected_result; |
| 42006 | long result; |
| 42007 | |
| 42008 | if (source2_s == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip200;} |
| 42009 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 42010 | |
| 42011 | expected_result = (long) (source1_l / source2_s); |
| 42012 | |
| 42013 | result = proc(source1_l, source2_s); |
| 42014 | if (expected_result != result) { |
| 42015 | printf("Failed long / short test, expected %ld, got %ld, for %ld / %d\n", |
| 42016 | expected_result, result, source1_l, source2_s); |
| 42017 | if (dumped == 0) cod_dump(gen_code); |
| 42018 | failed++; |
| 42019 | dumped++; |
| 42020 | } |
| 42021 | skip200: ; |
| 42022 | } |
| 42023 | } |
| 42024 | if (verbose) printf(" done\n"); |
| 42025 | cod_free_parse_context(context); |
| 42026 | cod_code_free(gen_code); |
| 42027 | } |
| 42028 | if ((only_run_test == NULL((void*)0)) || |
| 42029 | (strcmp(only_run_test, "l/us") == 0)) { |
| 42030 | int i, j; |
| 42031 | static char code[] = "{\n\ |
| 42032 | long a = p1;\n\ |
| 42033 | unsigned short b = p2;\n\ |
| 42034 | return a / b;\n\ |
| 42035 | }"; |
| 42036 | |
| 42037 | long (*proc)(long a, unsigned short b); |
| 42038 | cod_parse_context context = new_cod_parse_context(); |
| 42039 | int dumped = 0; |
| 42040 | |
| 42041 | cod_code gen_code; |
| 42042 | |
| 42043 | /* test for long / unsigned short */ |
| 42044 | if (verbose) printf("test for long / unsigned short"); |
| 42045 | |
| 42046 | cod_assoc_externs(context, externs); |
| 42047 | cod_parse_for_context(extern_string, context); |
| 42048 | |
| 42049 | cod_subroutine_declaration("long proc(long p1, unsigned short p2)", |
| 42050 | context); |
| 42051 | gen_code = cod_code_gen(code, context); |
| 42052 | proc = (long (*)(long, unsigned short))(long)gen_code->func; |
| 42053 | |
| 42054 | |
| 42055 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 42056 | long source1_l = src1l_vals[i]; |
| 42057 | for (j=0 ; j < sizeof(src2us_vals)/sizeof(src2us_vals[0]) ; j++) { |
| 42058 | unsigned short source2_us = src2us_vals[j]; |
| 42059 | |
| 42060 | long expected_result; |
| 42061 | long result; |
| 42062 | |
| 42063 | if (source2_us == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip201;} |
| 42064 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 42065 | |
| 42066 | expected_result = (long) (source1_l / source2_us); |
| 42067 | |
| 42068 | result = proc(source1_l, source2_us); |
| 42069 | if (expected_result != result) { |
| 42070 | printf("Failed long / unsigned short test, expected %ld, got %ld, for %ld / %u\n", |
| 42071 | expected_result, result, source1_l, source2_us); |
| 42072 | if (dumped == 0) cod_dump(gen_code); |
| 42073 | failed++; |
| 42074 | dumped++; |
| 42075 | } |
| 42076 | skip201: ; |
| 42077 | } |
| 42078 | } |
| 42079 | if (verbose) printf(" done\n"); |
| 42080 | cod_free_parse_context(context); |
| 42081 | cod_code_free(gen_code); |
| 42082 | } |
| 42083 | if ((only_run_test == NULL((void*)0)) || |
| 42084 | (strcmp(only_run_test, "l/i") == 0)) { |
| 42085 | int i, j; |
| 42086 | static char code[] = "{\n\ |
| 42087 | long a = p1;\n\ |
| 42088 | int b = p2;\n\ |
| 42089 | return a / b;\n\ |
| 42090 | }"; |
| 42091 | |
| 42092 | long (*proc)(long a, int b); |
| 42093 | cod_parse_context context = new_cod_parse_context(); |
| 42094 | int dumped = 0; |
| 42095 | |
| 42096 | cod_code gen_code; |
| 42097 | |
| 42098 | /* test for long / int */ |
| 42099 | if (verbose) printf("test for long / int"); |
| 42100 | |
| 42101 | cod_assoc_externs(context, externs); |
| 42102 | cod_parse_for_context(extern_string, context); |
| 42103 | |
| 42104 | cod_subroutine_declaration("long proc(long p1, int p2)", |
| 42105 | context); |
| 42106 | gen_code = cod_code_gen(code, context); |
| 42107 | proc = (long (*)(long, int))(long)gen_code->func; |
| 42108 | |
| 42109 | |
| 42110 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 42111 | long source1_l = src1l_vals[i]; |
| 42112 | for (j=0 ; j < sizeof(src2i_vals)/sizeof(src2i_vals[0]) ; j++) { |
| 42113 | int source2_i = src2i_vals[j]; |
| 42114 | |
| 42115 | long expected_result; |
| 42116 | long result; |
| 42117 | |
| 42118 | if (source2_i == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip202;} |
| 42119 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 42120 | |
| 42121 | expected_result = (long) (source1_l / source2_i); |
| 42122 | |
| 42123 | result = proc(source1_l, source2_i); |
| 42124 | if (expected_result != result) { |
| 42125 | printf("Failed long / int test, expected %ld, got %ld, for %ld / %d\n", |
| 42126 | expected_result, result, source1_l, source2_i); |
| 42127 | if (dumped == 0) cod_dump(gen_code); |
| 42128 | failed++; |
| 42129 | dumped++; |
| 42130 | } |
| 42131 | skip202: ; |
| 42132 | } |
| 42133 | } |
| 42134 | if (verbose) printf(" done\n"); |
| 42135 | cod_free_parse_context(context); |
| 42136 | cod_code_free(gen_code); |
| 42137 | } |
| 42138 | if ((only_run_test == NULL((void*)0)) || |
| 42139 | (strcmp(only_run_test, "l/u") == 0)) { |
| 42140 | int i, j; |
| 42141 | static char code[] = "{\n\ |
| 42142 | long a = p1;\n\ |
| 42143 | unsigned int b = p2;\n\ |
| 42144 | return a / b;\n\ |
| 42145 | }"; |
| 42146 | |
| 42147 | long (*proc)(long a, unsigned int b); |
| 42148 | cod_parse_context context = new_cod_parse_context(); |
| 42149 | int dumped = 0; |
| 42150 | |
| 42151 | cod_code gen_code; |
| 42152 | |
| 42153 | /* test for long / unsigned int */ |
| 42154 | if (verbose) printf("test for long / unsigned int"); |
| 42155 | |
| 42156 | cod_assoc_externs(context, externs); |
| 42157 | cod_parse_for_context(extern_string, context); |
| 42158 | |
| 42159 | cod_subroutine_declaration("long proc(long p1, unsigned int p2)", |
| 42160 | context); |
| 42161 | gen_code = cod_code_gen(code, context); |
| 42162 | proc = (long (*)(long, unsigned int))(long)gen_code->func; |
| 42163 | |
| 42164 | |
| 42165 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 42166 | long source1_l = src1l_vals[i]; |
| 42167 | for (j=0 ; j < sizeof(src2u_vals)/sizeof(src2u_vals[0]) ; j++) { |
| 42168 | unsigned int source2_u = src2u_vals[j]; |
| 42169 | |
| 42170 | long expected_result; |
| 42171 | long result; |
| 42172 | |
| 42173 | if (source2_u == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip203;} |
| 42174 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 42175 | |
| 42176 | expected_result = (long) (source1_l / source2_u); |
| 42177 | |
| 42178 | result = proc(source1_l, source2_u); |
| 42179 | if (expected_result != result) { |
| 42180 | printf("Failed long / unsigned int test, expected %ld, got %ld, for %ld / %u\n", |
| 42181 | expected_result, result, source1_l, source2_u); |
| 42182 | if (dumped == 0) cod_dump(gen_code); |
| 42183 | failed++; |
| 42184 | dumped++; |
| 42185 | } |
| 42186 | skip203: ; |
| 42187 | } |
| 42188 | } |
| 42189 | if (verbose) printf(" done\n"); |
| 42190 | cod_free_parse_context(context); |
| 42191 | cod_code_free(gen_code); |
| 42192 | } |
| 42193 | if ((only_run_test == NULL((void*)0)) || |
| 42194 | (strcmp(only_run_test, "l/ul") == 0)) { |
| 42195 | int i, j; |
| 42196 | static char code[] = "{\n\ |
| 42197 | long a = p1;\n\ |
| 42198 | unsigned long b = p2;\n\ |
| 42199 | return a / b;\n\ |
| 42200 | }"; |
| 42201 | |
| 42202 | long (*proc)(long a, unsigned long b); |
| 42203 | cod_parse_context context = new_cod_parse_context(); |
| 42204 | int dumped = 0; |
| 42205 | |
| 42206 | cod_code gen_code; |
| 42207 | |
| 42208 | /* test for long / unsigned long */ |
| 42209 | if (verbose) printf("test for long / unsigned long"); |
| 42210 | |
| 42211 | cod_assoc_externs(context, externs); |
| 42212 | cod_parse_for_context(extern_string, context); |
| 42213 | |
| 42214 | cod_subroutine_declaration("long proc(long p1, unsigned long p2)", |
| 42215 | context); |
| 42216 | gen_code = cod_code_gen(code, context); |
| 42217 | proc = (long (*)(long, unsigned long))(long)gen_code->func; |
| 42218 | |
| 42219 | |
| 42220 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 42221 | long source1_l = src1l_vals[i]; |
| 42222 | for (j=0 ; j < sizeof(src2ul_vals)/sizeof(src2ul_vals[0]) ; j++) { |
| 42223 | unsigned long source2_ul = src2ul_vals[j]; |
| 42224 | |
| 42225 | long expected_result; |
| 42226 | long result; |
| 42227 | |
| 42228 | if (source2_ul == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip204;} |
| 42229 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 42230 | |
| 42231 | expected_result = (long) (source1_l / source2_ul); |
| 42232 | |
| 42233 | result = proc(source1_l, source2_ul); |
| 42234 | if (expected_result != result) { |
| 42235 | printf("Failed long / unsigned long test, expected %ld, got %ld, for %ld / %lu\n", |
| 42236 | expected_result, result, source1_l, source2_ul); |
| 42237 | if (dumped == 0) cod_dump(gen_code); |
| 42238 | failed++; |
| 42239 | dumped++; |
| 42240 | } |
| 42241 | skip204: ; |
| 42242 | } |
| 42243 | } |
| 42244 | if (verbose) printf(" done\n"); |
| 42245 | cod_free_parse_context(context); |
| 42246 | cod_code_free(gen_code); |
| 42247 | } |
| 42248 | if ((only_run_test == NULL((void*)0)) || |
| 42249 | (strcmp(only_run_test, "l/l") == 0)) { |
| 42250 | int i, j; |
| 42251 | static char code[] = "{\n\ |
| 42252 | long a = p1;\n\ |
| 42253 | long b = p2;\n\ |
| 42254 | return a / b;\n\ |
| 42255 | }"; |
| 42256 | |
| 42257 | long (*proc)(long a, long b); |
| 42258 | cod_parse_context context = new_cod_parse_context(); |
| 42259 | int dumped = 0; |
| 42260 | |
| 42261 | cod_code gen_code; |
| 42262 | |
| 42263 | /* test for long / long */ |
| 42264 | if (verbose) printf("test for long / long"); |
| 42265 | |
| 42266 | cod_assoc_externs(context, externs); |
| 42267 | cod_parse_for_context(extern_string, context); |
| 42268 | |
| 42269 | cod_subroutine_declaration("long proc(long p1, long p2)", |
| 42270 | context); |
| 42271 | gen_code = cod_code_gen(code, context); |
| 42272 | proc = (long (*)(long, long))(long)gen_code->func; |
| 42273 | |
| 42274 | |
| 42275 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 42276 | long source1_l = src1l_vals[i]; |
| 42277 | for (j=0 ; j < sizeof(src2l_vals)/sizeof(src2l_vals[0]) ; j++) { |
| 42278 | long source2_l = src2l_vals[j]; |
| 42279 | |
| 42280 | long expected_result; |
| 42281 | long result; |
| 42282 | |
| 42283 | if (source2_l == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip205;} |
| 42284 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 42285 | |
| 42286 | expected_result = (long) (source1_l / source2_l); |
| 42287 | |
| 42288 | result = proc(source1_l, source2_l); |
| 42289 | if (expected_result != result) { |
| 42290 | printf("Failed long / long test, expected %ld, got %ld, for %ld / %ld\n", |
| 42291 | expected_result, result, source1_l, source2_l); |
| 42292 | if (dumped == 0) cod_dump(gen_code); |
| 42293 | failed++; |
| 42294 | dumped++; |
| 42295 | } |
| 42296 | skip205: ; |
| 42297 | } |
| 42298 | } |
| 42299 | if (verbose) printf(" done\n"); |
| 42300 | cod_free_parse_context(context); |
| 42301 | cod_code_free(gen_code); |
| 42302 | } |
| 42303 | if ((only_run_test == NULL((void*)0)) || |
| 42304 | (strcmp(only_run_test, "l/f") == 0)) { |
| 42305 | int i, j; |
| 42306 | static char code[] = "{\n\ |
| 42307 | long a = p1;\n\ |
| 42308 | float b = p2;\n\ |
| 42309 | return a / b;\n\ |
| 42310 | }"; |
| 42311 | |
| 42312 | long (*proc)(long a, float b); |
| 42313 | cod_parse_context context = new_cod_parse_context(); |
| 42314 | int dumped = 0; |
| 42315 | |
| 42316 | cod_code gen_code; |
| 42317 | |
| 42318 | /* test for long / float */ |
| 42319 | if (verbose) printf("test for long / float"); |
| 42320 | |
| 42321 | cod_assoc_externs(context, externs); |
| 42322 | cod_parse_for_context(extern_string, context); |
| 42323 | |
| 42324 | cod_subroutine_declaration("long proc(long p1, float p2)", |
| 42325 | context); |
| 42326 | gen_code = cod_code_gen(code, context); |
| 42327 | proc = (long (*)(long, float))(long)gen_code->func; |
| 42328 | |
| 42329 | |
| 42330 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 42331 | long source1_l = src1l_vals[i]; |
| 42332 | for (j=0 ; j < sizeof(src2f_vals)/sizeof(src2f_vals[0]) ; j++) { |
| 42333 | float source2_f = src2f_vals[j]; |
| 42334 | double range = 0.000001 * (fabs((double)source1_l / (double)source2_f)); |
| 42335 | long expected_result; |
| 42336 | long result; |
| 42337 | |
| 42338 | if (source2_f == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip206;} |
| 42339 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 42340 | |
| 42341 | expected_result = (long) (source1_l / source2_f); |
| 42342 | |
| 42343 | result = proc(source1_l, source2_f); |
| 42344 | range += 1.0; |
| 42345 | if ((result > (expected_result + range)) || (result < (expected_result - range))) { |
| 42346 | printf("Failed long / float test, expected %ld, got %ld, for %ld / %g\n", |
| 42347 | expected_result, result, source1_l, source2_f); |
| 42348 | if (dumped == 0) cod_dump(gen_code); |
| 42349 | failed++; |
| 42350 | dumped++; |
| 42351 | } |
| 42352 | skip206: ; |
| 42353 | } |
| 42354 | } |
| 42355 | if (verbose) printf(" done\n"); |
| 42356 | cod_free_parse_context(context); |
| 42357 | cod_code_free(gen_code); |
| 42358 | } |
| 42359 | if ((only_run_test == NULL((void*)0)) || |
| 42360 | (strcmp(only_run_test, "l/d") == 0)) { |
| 42361 | int i, j; |
| 42362 | static char code[] = "{\n\ |
| 42363 | long a = p1;\n\ |
| 42364 | double b = p2;\n\ |
| 42365 | return a / b;\n\ |
| 42366 | }"; |
| 42367 | |
| 42368 | long (*proc)(long a, double b); |
| 42369 | cod_parse_context context = new_cod_parse_context(); |
| 42370 | int dumped = 0; |
| 42371 | |
| 42372 | cod_code gen_code; |
| 42373 | |
| 42374 | /* test for long / double */ |
| 42375 | if (verbose) printf("test for long / double"); |
| 42376 | |
| 42377 | cod_assoc_externs(context, externs); |
| 42378 | cod_parse_for_context(extern_string, context); |
| 42379 | |
| 42380 | cod_subroutine_declaration("long proc(long p1, double p2)", |
| 42381 | context); |
| 42382 | gen_code = cod_code_gen(code, context); |
| 42383 | proc = (long (*)(long, double))(long)gen_code->func; |
| 42384 | |
| 42385 | |
| 42386 | for (i=0 ; i < sizeof(src1l_vals)/sizeof(src1l_vals[0]) ; i++) { |
| 42387 | long source1_l = src1l_vals[i]; |
| 42388 | for (j=0 ; j < sizeof(src2d_vals)/sizeof(src2d_vals[0]) ; j++) { |
| 42389 | double source2_d = src2d_vals[j]; |
| 42390 | |
| 42391 | long expected_result; |
| 42392 | long result; |
| 42393 | |
| 42394 | if (source2_d == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip207;} |
| 42395 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 42396 | |
| 42397 | expected_result = (long) (source1_l / source2_d); |
| 42398 | |
| 42399 | result = proc(source1_l, source2_d); |
| 42400 | if (expected_result != result) { |
| 42401 | printf("Failed long / double test, expected %ld, got %ld, for %ld / %g\n", |
| 42402 | expected_result, result, source1_l, source2_d); |
| 42403 | if (dumped == 0) cod_dump(gen_code); |
| 42404 | failed++; |
| 42405 | dumped++; |
| 42406 | } |
| 42407 | skip207: ; |
| 42408 | } |
| 42409 | } |
| 42410 | if (verbose) printf(" done\n"); |
| 42411 | cod_free_parse_context(context); |
| 42412 | cod_code_free(gen_code); |
| 42413 | } |
| 42414 | } |
| 42415 | void div_f_tests() |
| 42416 | { |
| 42417 | if ((only_run_test == NULL((void*)0)) || |
| 42418 | (strcmp(only_run_test, "f/c") == 0)) { |
| 42419 | int i, j; |
| 42420 | static char code[] = "{\n\ |
| 42421 | float a = p1;\n\ |
| 42422 | signed char b = p2;\n\ |
| 42423 | return a / b;\n\ |
| 42424 | }"; |
| 42425 | |
| 42426 | float (*proc)(float a, signed char b); |
| 42427 | cod_parse_context context = new_cod_parse_context(); |
| 42428 | int dumped = 0; |
| 42429 | |
| 42430 | cod_code gen_code; |
| 42431 | |
| 42432 | /* test for float / signed char */ |
| 42433 | if (verbose) printf("test for float / signed char"); |
| 42434 | |
| 42435 | cod_assoc_externs(context, externs); |
| 42436 | cod_parse_for_context(extern_string, context); |
| 42437 | |
| 42438 | cod_subroutine_declaration("float proc(float p1, signed char p2)", |
| 42439 | context); |
| 42440 | gen_code = cod_code_gen(code, context); |
| 42441 | proc = (float (*)(float, signed char))(long)gen_code->func; |
| 42442 | |
| 42443 | |
| 42444 | for (i=0 ; i < sizeof(src1f_vals)/sizeof(src1f_vals[0]) ; i++) { |
| 42445 | float source1_f = src1f_vals[i]; |
| 42446 | for (j=0 ; j < sizeof(src2c_vals)/sizeof(src2c_vals[0]) ; j++) { |
| 42447 | signed char source2_c = src2c_vals[j]; |
| 42448 | double range = 0.000001 * (fabs((double)source1_f / (double)source2_c)); |
| 42449 | float expected_result; |
| 42450 | float result; |
| 42451 | |
| 42452 | if (source2_c == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip208;} |
| 42453 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 42454 | |
| 42455 | expected_result = (float) (source1_f / source2_c); |
| 42456 | |
| 42457 | result = proc(source1_f, source2_c); |
| 42458 | range += 1.0; |
| 42459 | if ((result > (expected_result + range)) || (result < (expected_result - range))) { |
| 42460 | printf("Failed float / signed char test, expected %g, got %g, for %g / %d\n", |
| 42461 | expected_result, result, source1_f, source2_c); |
| 42462 | if (dumped == 0) cod_dump(gen_code); |
| 42463 | failed++; |
| 42464 | dumped++; |
| 42465 | } |
| 42466 | skip208: ; |
| 42467 | } |
| 42468 | } |
| 42469 | if (verbose) printf(" done\n"); |
| 42470 | cod_free_parse_context(context); |
| 42471 | cod_code_free(gen_code); |
| 42472 | } |
| 42473 | if ((only_run_test == NULL((void*)0)) || |
| 42474 | (strcmp(only_run_test, "f/uc") == 0)) { |
| 42475 | int i, j; |
| 42476 | static char code[] = "{\n\ |
| 42477 | float a = p1;\n\ |
| 42478 | unsigned char b = p2;\n\ |
| 42479 | return a / b;\n\ |
| 42480 | }"; |
| 42481 | |
| 42482 | float (*proc)(float a, unsigned char b); |
| 42483 | cod_parse_context context = new_cod_parse_context(); |
| 42484 | int dumped = 0; |
| 42485 | |
| 42486 | cod_code gen_code; |
| 42487 | |
| 42488 | /* test for float / unsigned char */ |
| 42489 | if (verbose) printf("test for float / unsigned char"); |
| 42490 | |
| 42491 | cod_assoc_externs(context, externs); |
| 42492 | cod_parse_for_context(extern_string, context); |
| 42493 | |
| 42494 | cod_subroutine_declaration("float proc(float p1, unsigned char p2)", |
| 42495 | context); |
| 42496 | gen_code = cod_code_gen(code, context); |
| 42497 | proc = (float (*)(float, unsigned char))(long)gen_code->func; |
| 42498 | |
| 42499 | |
| 42500 | for (i=0 ; i < sizeof(src1f_vals)/sizeof(src1f_vals[0]) ; i++) { |
| 42501 | float source1_f = src1f_vals[i]; |
| 42502 | for (j=0 ; j < sizeof(src2uc_vals)/sizeof(src2uc_vals[0]) ; j++) { |
| 42503 | unsigned char source2_uc = src2uc_vals[j]; |
| 42504 | double range = 0.000001 * (fabs((double)source1_f / (double)source2_uc)); |
| 42505 | float expected_result; |
| 42506 | float result; |
| 42507 | |
| 42508 | if (source2_uc == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip209;} |
| 42509 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 42510 | |
| 42511 | expected_result = (float) (source1_f / source2_uc); |
| 42512 | |
| 42513 | result = proc(source1_f, source2_uc); |
| 42514 | range += 1.0; |
| 42515 | if ((result > (expected_result + range)) || (result < (expected_result - range))) { |
| 42516 | printf("Failed float / unsigned char test, expected %g, got %g, for %g / %u\n", |
| 42517 | expected_result, result, source1_f, source2_uc); |
| 42518 | if (dumped == 0) cod_dump(gen_code); |
| 42519 | failed++; |
| 42520 | dumped++; |
| 42521 | } |
| 42522 | skip209: ; |
| 42523 | } |
| 42524 | } |
| 42525 | if (verbose) printf(" done\n"); |
| 42526 | cod_free_parse_context(context); |
| 42527 | cod_code_free(gen_code); |
| 42528 | } |
| 42529 | if ((only_run_test == NULL((void*)0)) || |
| 42530 | (strcmp(only_run_test, "f/s") == 0)) { |
| 42531 | int i, j; |
| 42532 | static char code[] = "{\n\ |
| 42533 | float a = p1;\n\ |
| 42534 | short b = p2;\n\ |
| 42535 | return a / b;\n\ |
| 42536 | }"; |
| 42537 | |
| 42538 | float (*proc)(float a, short b); |
| 42539 | cod_parse_context context = new_cod_parse_context(); |
| 42540 | int dumped = 0; |
| 42541 | |
| 42542 | cod_code gen_code; |
| 42543 | |
| 42544 | /* test for float / short */ |
| 42545 | if (verbose) printf("test for float / short"); |
| 42546 | |
| 42547 | cod_assoc_externs(context, externs); |
| 42548 | cod_parse_for_context(extern_string, context); |
| 42549 | |
| 42550 | cod_subroutine_declaration("float proc(float p1, short p2)", |
| 42551 | context); |
| 42552 | gen_code = cod_code_gen(code, context); |
| 42553 | proc = (float (*)(float, short))(long)gen_code->func; |
| 42554 | |
| 42555 | |
| 42556 | for (i=0 ; i < sizeof(src1f_vals)/sizeof(src1f_vals[0]) ; i++) { |
| 42557 | float source1_f = src1f_vals[i]; |
| 42558 | for (j=0 ; j < sizeof(src2s_vals)/sizeof(src2s_vals[0]) ; j++) { |
| 42559 | short source2_s = src2s_vals[j]; |
| 42560 | double range = 0.000001 * (fabs((double)source1_f / (double)source2_s)); |
| 42561 | float expected_result; |
| 42562 | float result; |
| 42563 | |
| 42564 | if (source2_s == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip210;} |
| 42565 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 42566 | |
| 42567 | expected_result = (float) (source1_f / source2_s); |
| 42568 | |
| 42569 | result = proc(source1_f, source2_s); |
| 42570 | range += 1.0; |
| 42571 | if ((result > (expected_result + range)) || (result < (expected_result - range))) { |
| 42572 | printf("Failed float / short test, expected %g, got %g, for %g / %d\n", |
| 42573 | expected_result, result, source1_f, source2_s); |
| 42574 | if (dumped == 0) cod_dump(gen_code); |
| 42575 | failed++; |
| 42576 | dumped++; |
| 42577 | } |
| 42578 | skip210: ; |
| 42579 | } |
| 42580 | } |
| 42581 | if (verbose) printf(" done\n"); |
| 42582 | cod_free_parse_context(context); |
| 42583 | cod_code_free(gen_code); |
| 42584 | } |
| 42585 | if ((only_run_test == NULL((void*)0)) || |
| 42586 | (strcmp(only_run_test, "f/us") == 0)) { |
| 42587 | int i, j; |
| 42588 | static char code[] = "{\n\ |
| 42589 | float a = p1;\n\ |
| 42590 | unsigned short b = p2;\n\ |
| 42591 | return a / b;\n\ |
| 42592 | }"; |
| 42593 | |
| 42594 | float (*proc)(float a, unsigned short b); |
| 42595 | cod_parse_context context = new_cod_parse_context(); |
| 42596 | int dumped = 0; |
| 42597 | |
| 42598 | cod_code gen_code; |
| 42599 | |
| 42600 | /* test for float / unsigned short */ |
| 42601 | if (verbose) printf("test for float / unsigned short"); |
| 42602 | |
| 42603 | cod_assoc_externs(context, externs); |
| 42604 | cod_parse_for_context(extern_string, context); |
| 42605 | |
| 42606 | cod_subroutine_declaration("float proc(float p1, unsigned short p2)", |
| 42607 | context); |
| 42608 | gen_code = cod_code_gen(code, context); |
| 42609 | proc = (float (*)(float, unsigned short))(long)gen_code->func; |
| 42610 | |
| 42611 | |
| 42612 | for (i=0 ; i < sizeof(src1f_vals)/sizeof(src1f_vals[0]) ; i++) { |
| 42613 | float source1_f = src1f_vals[i]; |
| 42614 | for (j=0 ; j < sizeof(src2us_vals)/sizeof(src2us_vals[0]) ; j++) { |
| 42615 | unsigned short source2_us = src2us_vals[j]; |
| 42616 | double range = 0.000001 * (fabs((double)source1_f / (double)source2_us)); |
| 42617 | float expected_result; |
| 42618 | float result; |
| 42619 | |
| 42620 | if (source2_us == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip211;} |
| 42621 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 42622 | |
| 42623 | expected_result = (float) (source1_f / source2_us); |
| 42624 | |
| 42625 | result = proc(source1_f, source2_us); |
| 42626 | range += 1.0; |
| 42627 | if ((result > (expected_result + range)) || (result < (expected_result - range))) { |
| 42628 | printf("Failed float / unsigned short test, expected %g, got %g, for %g / %u\n", |
| 42629 | expected_result, result, source1_f, source2_us); |
| 42630 | if (dumped == 0) cod_dump(gen_code); |
| 42631 | failed++; |
| 42632 | dumped++; |
| 42633 | } |
| 42634 | skip211: ; |
| 42635 | } |
| 42636 | } |
| 42637 | if (verbose) printf(" done\n"); |
| 42638 | cod_free_parse_context(context); |
| 42639 | cod_code_free(gen_code); |
| 42640 | } |
| 42641 | if ((only_run_test == NULL((void*)0)) || |
| 42642 | (strcmp(only_run_test, "f/i") == 0)) { |
| 42643 | int i, j; |
| 42644 | static char code[] = "{\n\ |
| 42645 | float a = p1;\n\ |
| 42646 | int b = p2;\n\ |
| 42647 | return a / b;\n\ |
| 42648 | }"; |
| 42649 | |
| 42650 | float (*proc)(float a, int b); |
| 42651 | cod_parse_context context = new_cod_parse_context(); |
| 42652 | int dumped = 0; |
| 42653 | |
| 42654 | cod_code gen_code; |
| 42655 | |
| 42656 | /* test for float / int */ |
| 42657 | if (verbose) printf("test for float / int"); |
| 42658 | |
| 42659 | cod_assoc_externs(context, externs); |
| 42660 | cod_parse_for_context(extern_string, context); |
| 42661 | |
| 42662 | cod_subroutine_declaration("float proc(float p1, int p2)", |
| 42663 | context); |
| 42664 | gen_code = cod_code_gen(code, context); |
| 42665 | proc = (float (*)(float, int))(long)gen_code->func; |
| 42666 | |
| 42667 | |
| 42668 | for (i=0 ; i < sizeof(src1f_vals)/sizeof(src1f_vals[0]) ; i++) { |
| 42669 | float source1_f = src1f_vals[i]; |
| 42670 | for (j=0 ; j < sizeof(src2i_vals)/sizeof(src2i_vals[0]) ; j++) { |
| 42671 | int source2_i = src2i_vals[j]; |
| 42672 | double range = 0.000001 * (fabs((double)source1_f / (double)source2_i)); |
| 42673 | float expected_result; |
| 42674 | float result; |
| 42675 | |
| 42676 | if (source2_i == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip212;} |
| 42677 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 42678 | |
| 42679 | expected_result = (float) (source1_f / source2_i); |
| 42680 | |
| 42681 | result = proc(source1_f, source2_i); |
| 42682 | range += 1.0; |
| 42683 | if ((result > (expected_result + range)) || (result < (expected_result - range))) { |
| 42684 | printf("Failed float / int test, expected %g, got %g, for %g / %d\n", |
| 42685 | expected_result, result, source1_f, source2_i); |
| 42686 | if (dumped == 0) cod_dump(gen_code); |
| 42687 | failed++; |
| 42688 | dumped++; |
| 42689 | } |
| 42690 | skip212: ; |
| 42691 | } |
| 42692 | } |
| 42693 | if (verbose) printf(" done\n"); |
| 42694 | cod_free_parse_context(context); |
| 42695 | cod_code_free(gen_code); |
| 42696 | } |
| 42697 | if ((only_run_test == NULL((void*)0)) || |
| 42698 | (strcmp(only_run_test, "f/u") == 0)) { |
| 42699 | int i, j; |
| 42700 | static char code[] = "{\n\ |
| 42701 | float a = p1;\n\ |
| 42702 | unsigned int b = p2;\n\ |
| 42703 | return a / b;\n\ |
| 42704 | }"; |
| 42705 | |
| 42706 | float (*proc)(float a, unsigned int b); |
| 42707 | cod_parse_context context = new_cod_parse_context(); |
| 42708 | int dumped = 0; |
| 42709 | |
| 42710 | cod_code gen_code; |
| 42711 | |
| 42712 | /* test for float / unsigned int */ |
| 42713 | if (verbose) printf("test for float / unsigned int"); |
| 42714 | |
| 42715 | cod_assoc_externs(context, externs); |
| 42716 | cod_parse_for_context(extern_string, context); |
| 42717 | |
| 42718 | cod_subroutine_declaration("float proc(float p1, unsigned int p2)", |
| 42719 | context); |
| 42720 | gen_code = cod_code_gen(code, context); |
| 42721 | proc = (float (*)(float, unsigned int))(long)gen_code->func; |
| 42722 | |
| 42723 | |
| 42724 | for (i=0 ; i < sizeof(src1f_vals)/sizeof(src1f_vals[0]) ; i++) { |
| 42725 | float source1_f = src1f_vals[i]; |
| 42726 | for (j=0 ; j < sizeof(src2u_vals)/sizeof(src2u_vals[0]) ; j++) { |
| 42727 | unsigned int source2_u = src2u_vals[j]; |
| 42728 | double range = 0.000001 * (fabs((double)source1_f / (double)source2_u)); |
| 42729 | float expected_result; |
| 42730 | float result; |
| 42731 | |
| 42732 | if (source2_u == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip213;} |
| 42733 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 42734 | |
| 42735 | expected_result = (float) (source1_f / source2_u); |
| 42736 | |
| 42737 | result = proc(source1_f, source2_u); |
| 42738 | range += 1.0; |
| 42739 | if ((result > (expected_result + range)) || (result < (expected_result - range))) { |
| 42740 | printf("Failed float / unsigned int test, expected %g, got %g, for %g / %u\n", |
| 42741 | expected_result, result, source1_f, source2_u); |
| 42742 | if (dumped == 0) cod_dump(gen_code); |
| 42743 | failed++; |
| 42744 | dumped++; |
| 42745 | } |
| 42746 | skip213: ; |
| 42747 | } |
| 42748 | } |
| 42749 | if (verbose) printf(" done\n"); |
| 42750 | cod_free_parse_context(context); |
| 42751 | cod_code_free(gen_code); |
| 42752 | } |
| 42753 | if ((only_run_test == NULL((void*)0)) || |
| 42754 | (strcmp(only_run_test, "f/ul") == 0)) { |
| 42755 | int i, j; |
| 42756 | static char code[] = "{\n\ |
| 42757 | float a = p1;\n\ |
| 42758 | unsigned long b = p2;\n\ |
| 42759 | return a / b;\n\ |
| 42760 | }"; |
| 42761 | |
| 42762 | float (*proc)(float a, unsigned long b); |
| 42763 | cod_parse_context context = new_cod_parse_context(); |
| 42764 | int dumped = 0; |
| 42765 | |
| 42766 | cod_code gen_code; |
| 42767 | |
| 42768 | /* test for float / unsigned long */ |
| 42769 | if (verbose) printf("test for float / unsigned long"); |
| 42770 | |
| 42771 | cod_assoc_externs(context, externs); |
| 42772 | cod_parse_for_context(extern_string, context); |
| 42773 | |
| 42774 | cod_subroutine_declaration("float proc(float p1, unsigned long p2)", |
| 42775 | context); |
| 42776 | gen_code = cod_code_gen(code, context); |
| 42777 | proc = (float (*)(float, unsigned long))(long)gen_code->func; |
| 42778 | |
| 42779 | |
| 42780 | for (i=0 ; i < sizeof(src1f_vals)/sizeof(src1f_vals[0]) ; i++) { |
| 42781 | float source1_f = src1f_vals[i]; |
| 42782 | for (j=0 ; j < sizeof(src2ul_vals)/sizeof(src2ul_vals[0]) ; j++) { |
| 42783 | unsigned long source2_ul = src2ul_vals[j]; |
| 42784 | double range = 0.000001 * (fabs((double)source1_f / (double)source2_ul)); |
| 42785 | float expected_result; |
| 42786 | float result; |
| 42787 | |
| 42788 | if (source2_ul == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip214;} |
| 42789 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 42790 | |
| 42791 | expected_result = (float) (source1_f / source2_ul); |
| 42792 | |
| 42793 | result = proc(source1_f, source2_ul); |
| 42794 | range += 1.0; |
| 42795 | if ((result > (expected_result + range)) || (result < (expected_result - range))) { |
| 42796 | printf("Failed float / unsigned long test, expected %g, got %g, for %g / %lu\n", |
| 42797 | expected_result, result, source1_f, source2_ul); |
| 42798 | if (dumped == 0) cod_dump(gen_code); |
| 42799 | failed++; |
| 42800 | dumped++; |
| 42801 | } |
| 42802 | skip214: ; |
| 42803 | } |
| 42804 | } |
| 42805 | if (verbose) printf(" done\n"); |
| 42806 | cod_free_parse_context(context); |
| 42807 | cod_code_free(gen_code); |
| 42808 | } |
| 42809 | if ((only_run_test == NULL((void*)0)) || |
| 42810 | (strcmp(only_run_test, "f/l") == 0)) { |
| 42811 | int i, j; |
| 42812 | static char code[] = "{\n\ |
| 42813 | float a = p1;\n\ |
| 42814 | long b = p2;\n\ |
| 42815 | return a / b;\n\ |
| 42816 | }"; |
| 42817 | |
| 42818 | float (*proc)(float a, long b); |
| 42819 | cod_parse_context context = new_cod_parse_context(); |
| 42820 | int dumped = 0; |
| 42821 | |
| 42822 | cod_code gen_code; |
| 42823 | |
| 42824 | /* test for float / long */ |
| 42825 | if (verbose) printf("test for float / long"); |
| 42826 | |
| 42827 | cod_assoc_externs(context, externs); |
| 42828 | cod_parse_for_context(extern_string, context); |
| 42829 | |
| 42830 | cod_subroutine_declaration("float proc(float p1, long p2)", |
| 42831 | context); |
| 42832 | gen_code = cod_code_gen(code, context); |
| 42833 | proc = (float (*)(float, long))(long)gen_code->func; |
| 42834 | |
| 42835 | |
| 42836 | for (i=0 ; i < sizeof(src1f_vals)/sizeof(src1f_vals[0]) ; i++) { |
| 42837 | float source1_f = src1f_vals[i]; |
| 42838 | for (j=0 ; j < sizeof(src2l_vals)/sizeof(src2l_vals[0]) ; j++) { |
| 42839 | long source2_l = src2l_vals[j]; |
| 42840 | double range = 0.000001 * (fabs((double)source1_f / (double)source2_l)); |
| 42841 | float expected_result; |
| 42842 | float result; |
| 42843 | |
| 42844 | if (source2_l == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip215;} |
| 42845 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 42846 | |
| 42847 | expected_result = (float) (source1_f / source2_l); |
| 42848 | |
| 42849 | result = proc(source1_f, source2_l); |
| 42850 | range += 1.0; |
| 42851 | if ((result > (expected_result + range)) || (result < (expected_result - range))) { |
| 42852 | printf("Failed float / long test, expected %g, got %g, for %g / %ld\n", |
| 42853 | expected_result, result, source1_f, source2_l); |
| 42854 | if (dumped == 0) cod_dump(gen_code); |
| 42855 | failed++; |
| 42856 | dumped++; |
| 42857 | } |
| 42858 | skip215: ; |
| 42859 | } |
| 42860 | } |
| 42861 | if (verbose) printf(" done\n"); |
| 42862 | cod_free_parse_context(context); |
| 42863 | cod_code_free(gen_code); |
| 42864 | } |
| 42865 | if ((only_run_test == NULL((void*)0)) || |
| 42866 | (strcmp(only_run_test, "f/f") == 0)) { |
| 42867 | int i, j; |
| 42868 | static char code[] = "{\n\ |
| 42869 | float a = p1;\n\ |
| 42870 | float b = p2;\n\ |
| 42871 | return a / b;\n\ |
| 42872 | }"; |
| 42873 | |
| 42874 | float (*proc)(float a, float b); |
| 42875 | cod_parse_context context = new_cod_parse_context(); |
| 42876 | int dumped = 0; |
| 42877 | |
| 42878 | cod_code gen_code; |
| 42879 | |
| 42880 | /* test for float / float */ |
| 42881 | if (verbose) printf("test for float / float"); |
| 42882 | |
| 42883 | cod_assoc_externs(context, externs); |
| 42884 | cod_parse_for_context(extern_string, context); |
| 42885 | |
| 42886 | cod_subroutine_declaration("float proc(float p1, float p2)", |
| 42887 | context); |
| 42888 | gen_code = cod_code_gen(code, context); |
| 42889 | proc = (float (*)(float, float))(long)gen_code->func; |
| 42890 | |
| 42891 | |
| 42892 | for (i=0 ; i < sizeof(src1f_vals)/sizeof(src1f_vals[0]) ; i++) { |
| 42893 | float source1_f = src1f_vals[i]; |
| 42894 | for (j=0 ; j < sizeof(src2f_vals)/sizeof(src2f_vals[0]) ; j++) { |
| 42895 | float source2_f = src2f_vals[j]; |
| 42896 | double range = 0.000001 * (fabs((double)source1_f / (double)source2_f)); |
| 42897 | float expected_result; |
| 42898 | float result; |
| 42899 | |
| 42900 | if (source2_f == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip216;} |
| 42901 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 42902 | |
| 42903 | expected_result = (float) (source1_f / source2_f); |
| 42904 | |
| 42905 | result = proc(source1_f, source2_f); |
| 42906 | if ((result > (expected_result + range)) || (result < (expected_result - range))) { |
| 42907 | printf("Failed float / float test, expected %g, got %g, for %g / %g\n", |
| 42908 | expected_result, result, source1_f, source2_f); |
| 42909 | if (dumped == 0) cod_dump(gen_code); |
| 42910 | failed++; |
| 42911 | dumped++; |
| 42912 | } |
| 42913 | skip216: ; |
| 42914 | } |
| 42915 | } |
| 42916 | if (verbose) printf(" done\n"); |
| 42917 | cod_free_parse_context(context); |
| 42918 | cod_code_free(gen_code); |
| 42919 | } |
| 42920 | if ((only_run_test == NULL((void*)0)) || |
| 42921 | (strcmp(only_run_test, "f/d") == 0)) { |
| 42922 | int i, j; |
| 42923 | static char code[] = "{\n\ |
| 42924 | float a = p1;\n\ |
| 42925 | double b = p2;\n\ |
| 42926 | return a / b;\n\ |
| 42927 | }"; |
| 42928 | |
| 42929 | float (*proc)(float a, double b); |
| 42930 | cod_parse_context context = new_cod_parse_context(); |
| 42931 | int dumped = 0; |
| 42932 | |
| 42933 | cod_code gen_code; |
| 42934 | |
| 42935 | /* test for float / double */ |
| 42936 | if (verbose) printf("test for float / double"); |
| 42937 | |
| 42938 | cod_assoc_externs(context, externs); |
| 42939 | cod_parse_for_context(extern_string, context); |
| 42940 | |
| 42941 | cod_subroutine_declaration("float proc(float p1, double p2)", |
| 42942 | context); |
| 42943 | gen_code = cod_code_gen(code, context); |
| 42944 | proc = (float (*)(float, double))(long)gen_code->func; |
| 42945 | |
| 42946 | |
| 42947 | for (i=0 ; i < sizeof(src1f_vals)/sizeof(src1f_vals[0]) ; i++) { |
| 42948 | float source1_f = src1f_vals[i]; |
| 42949 | for (j=0 ; j < sizeof(src2d_vals)/sizeof(src2d_vals[0]) ; j++) { |
| 42950 | double source2_d = src2d_vals[j]; |
| 42951 | double range = 0.000001 * (fabs((double)source1_f / (double)source2_d)); |
| 42952 | float expected_result; |
| 42953 | float result; |
| 42954 | |
| 42955 | if (source2_d == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip217;} |
| 42956 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 42957 | |
| 42958 | expected_result = (float) (source1_f / source2_d); |
| 42959 | |
| 42960 | result = proc(source1_f, source2_d); |
| 42961 | range += 1.0; |
| 42962 | if ((result > (expected_result + range)) || (result < (expected_result - range))) { |
| 42963 | printf("Failed float / double test, expected %g, got %g, for %g / %g\n", |
| 42964 | expected_result, result, source1_f, source2_d); |
| 42965 | if (dumped == 0) cod_dump(gen_code); |
| 42966 | failed++; |
| 42967 | dumped++; |
| 42968 | } |
| 42969 | skip217: ; |
| 42970 | } |
| 42971 | } |
| 42972 | if (verbose) printf(" done\n"); |
| 42973 | cod_free_parse_context(context); |
| 42974 | cod_code_free(gen_code); |
| 42975 | } |
| 42976 | } |
| 42977 | void div_d_tests() |
| 42978 | { |
| 42979 | if ((only_run_test == NULL((void*)0)) || |
| 42980 | (strcmp(only_run_test, "d/c") == 0)) { |
| 42981 | int i, j; |
| 42982 | static char code[] = "{\n\ |
| 42983 | double a = p1;\n\ |
| 42984 | signed char b = p2;\n\ |
| 42985 | return a / b;\n\ |
| 42986 | }"; |
| 42987 | |
| 42988 | double (*proc)(double a, signed char b); |
| 42989 | cod_parse_context context = new_cod_parse_context(); |
| 42990 | int dumped = 0; |
| 42991 | |
| 42992 | cod_code gen_code; |
| 42993 | |
| 42994 | /* test for double / signed char */ |
| 42995 | if (verbose) printf("test for double / signed char"); |
| 42996 | |
| 42997 | cod_assoc_externs(context, externs); |
| 42998 | cod_parse_for_context(extern_string, context); |
| 42999 | |
| 43000 | cod_subroutine_declaration("double proc(double p1, signed char p2)", |
| 43001 | context); |
| 43002 | gen_code = cod_code_gen(code, context); |
| 43003 | proc = (double (*)(double, signed char))(long)gen_code->func; |
| 43004 | |
| 43005 | |
| 43006 | for (i=0 ; i < sizeof(src1d_vals)/sizeof(src1d_vals[0]) ; i++) { |
| 43007 | double source1_d = src1d_vals[i]; |
| 43008 | for (j=0 ; j < sizeof(src2c_vals)/sizeof(src2c_vals[0]) ; j++) { |
| 43009 | signed char source2_c = src2c_vals[j]; |
| 43010 | |
| 43011 | double expected_result; |
| 43012 | double result; |
| 43013 | |
| 43014 | if (source2_c == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip218;} |
| 43015 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 43016 | |
| 43017 | expected_result = (double) (source1_d / source2_c); |
| 43018 | |
| 43019 | result = proc(source1_d, source2_c); |
| 43020 | if (expected_result != result) { |
| 43021 | printf("Failed double / signed char test, expected %g, got %g, for %g / %d\n", |
| 43022 | expected_result, result, source1_d, source2_c); |
| 43023 | if (dumped == 0) cod_dump(gen_code); |
| 43024 | failed++; |
| 43025 | dumped++; |
| 43026 | } |
| 43027 | skip218: ; |
| 43028 | } |
| 43029 | } |
| 43030 | if (verbose) printf(" done\n"); |
| 43031 | cod_free_parse_context(context); |
| 43032 | cod_code_free(gen_code); |
| 43033 | } |
| 43034 | if ((only_run_test == NULL((void*)0)) || |
| 43035 | (strcmp(only_run_test, "d/uc") == 0)) { |
| 43036 | int i, j; |
| 43037 | static char code[] = "{\n\ |
| 43038 | double a = p1;\n\ |
| 43039 | unsigned char b = p2;\n\ |
| 43040 | return a / b;\n\ |
| 43041 | }"; |
| 43042 | |
| 43043 | double (*proc)(double a, unsigned char b); |
| 43044 | cod_parse_context context = new_cod_parse_context(); |
| 43045 | int dumped = 0; |
| 43046 | |
| 43047 | cod_code gen_code; |
| 43048 | |
| 43049 | /* test for double / unsigned char */ |
| 43050 | if (verbose) printf("test for double / unsigned char"); |
| 43051 | |
| 43052 | cod_assoc_externs(context, externs); |
| 43053 | cod_parse_for_context(extern_string, context); |
| 43054 | |
| 43055 | cod_subroutine_declaration("double proc(double p1, unsigned char p2)", |
| 43056 | context); |
| 43057 | gen_code = cod_code_gen(code, context); |
| 43058 | proc = (double (*)(double, unsigned char))(long)gen_code->func; |
| 43059 | |
| 43060 | |
| 43061 | for (i=0 ; i < sizeof(src1d_vals)/sizeof(src1d_vals[0]) ; i++) { |
| 43062 | double source1_d = src1d_vals[i]; |
| 43063 | for (j=0 ; j < sizeof(src2uc_vals)/sizeof(src2uc_vals[0]) ; j++) { |
| 43064 | unsigned char source2_uc = src2uc_vals[j]; |
| 43065 | |
| 43066 | double expected_result; |
| 43067 | double result; |
| 43068 | |
| 43069 | if (source2_uc == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip219;} |
| 43070 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 43071 | |
| 43072 | expected_result = (double) (source1_d / source2_uc); |
| 43073 | |
| 43074 | result = proc(source1_d, source2_uc); |
| 43075 | if (expected_result != result) { |
| 43076 | printf("Failed double / unsigned char test, expected %g, got %g, for %g / %u\n", |
| 43077 | expected_result, result, source1_d, source2_uc); |
| 43078 | if (dumped == 0) cod_dump(gen_code); |
| 43079 | failed++; |
| 43080 | dumped++; |
| 43081 | } |
| 43082 | skip219: ; |
| 43083 | } |
| 43084 | } |
| 43085 | if (verbose) printf(" done\n"); |
| 43086 | cod_free_parse_context(context); |
| 43087 | cod_code_free(gen_code); |
| 43088 | } |
| 43089 | if ((only_run_test == NULL((void*)0)) || |
| 43090 | (strcmp(only_run_test, "d/s") == 0)) { |
| 43091 | int i, j; |
| 43092 | static char code[] = "{\n\ |
| 43093 | double a = p1;\n\ |
| 43094 | short b = p2;\n\ |
| 43095 | return a / b;\n\ |
| 43096 | }"; |
| 43097 | |
| 43098 | double (*proc)(double a, short b); |
| 43099 | cod_parse_context context = new_cod_parse_context(); |
| 43100 | int dumped = 0; |
| 43101 | |
| 43102 | cod_code gen_code; |
| 43103 | |
| 43104 | /* test for double / short */ |
| 43105 | if (verbose) printf("test for double / short"); |
| 43106 | |
| 43107 | cod_assoc_externs(context, externs); |
| 43108 | cod_parse_for_context(extern_string, context); |
| 43109 | |
| 43110 | cod_subroutine_declaration("double proc(double p1, short p2)", |
| 43111 | context); |
| 43112 | gen_code = cod_code_gen(code, context); |
| 43113 | proc = (double (*)(double, short))(long)gen_code->func; |
| 43114 | |
| 43115 | |
| 43116 | for (i=0 ; i < sizeof(src1d_vals)/sizeof(src1d_vals[0]) ; i++) { |
| 43117 | double source1_d = src1d_vals[i]; |
| 43118 | for (j=0 ; j < sizeof(src2s_vals)/sizeof(src2s_vals[0]) ; j++) { |
| 43119 | short source2_s = src2s_vals[j]; |
| 43120 | |
| 43121 | double expected_result; |
| 43122 | double result; |
| 43123 | |
| 43124 | if (source2_s == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip220;} |
| 43125 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 43126 | |
| 43127 | expected_result = (double) (source1_d / source2_s); |
| 43128 | |
| 43129 | result = proc(source1_d, source2_s); |
| 43130 | if (expected_result != result) { |
| 43131 | printf("Failed double / short test, expected %g, got %g, for %g / %d\n", |
| 43132 | expected_result, result, source1_d, source2_s); |
| 43133 | if (dumped == 0) cod_dump(gen_code); |
| 43134 | failed++; |
| 43135 | dumped++; |
| 43136 | } |
| 43137 | skip220: ; |
| 43138 | } |
| 43139 | } |
| 43140 | if (verbose) printf(" done\n"); |
| 43141 | cod_free_parse_context(context); |
| 43142 | cod_code_free(gen_code); |
| 43143 | } |
| 43144 | if ((only_run_test == NULL((void*)0)) || |
| 43145 | (strcmp(only_run_test, "d/us") == 0)) { |
| 43146 | int i, j; |
| 43147 | static char code[] = "{\n\ |
| 43148 | double a = p1;\n\ |
| 43149 | unsigned short b = p2;\n\ |
| 43150 | return a / b;\n\ |
| 43151 | }"; |
| 43152 | |
| 43153 | double (*proc)(double a, unsigned short b); |
| 43154 | cod_parse_context context = new_cod_parse_context(); |
| 43155 | int dumped = 0; |
| 43156 | |
| 43157 | cod_code gen_code; |
| 43158 | |
| 43159 | /* test for double / unsigned short */ |
| 43160 | if (verbose) printf("test for double / unsigned short"); |
| 43161 | |
| 43162 | cod_assoc_externs(context, externs); |
| 43163 | cod_parse_for_context(extern_string, context); |
| 43164 | |
| 43165 | cod_subroutine_declaration("double proc(double p1, unsigned short p2)", |
| 43166 | context); |
| 43167 | gen_code = cod_code_gen(code, context); |
| 43168 | proc = (double (*)(double, unsigned short))(long)gen_code->func; |
| 43169 | |
| 43170 | |
| 43171 | for (i=0 ; i < sizeof(src1d_vals)/sizeof(src1d_vals[0]) ; i++) { |
| 43172 | double source1_d = src1d_vals[i]; |
| 43173 | for (j=0 ; j < sizeof(src2us_vals)/sizeof(src2us_vals[0]) ; j++) { |
| 43174 | unsigned short source2_us = src2us_vals[j]; |
| 43175 | |
| 43176 | double expected_result; |
| 43177 | double result; |
| 43178 | |
| 43179 | if (source2_us == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip221;} |
| 43180 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 43181 | |
| 43182 | expected_result = (double) (source1_d / source2_us); |
| 43183 | |
| 43184 | result = proc(source1_d, source2_us); |
| 43185 | if (expected_result != result) { |
| 43186 | printf("Failed double / unsigned short test, expected %g, got %g, for %g / %u\n", |
| 43187 | expected_result, result, source1_d, source2_us); |
| 43188 | if (dumped == 0) cod_dump(gen_code); |
| 43189 | failed++; |
| 43190 | dumped++; |
| 43191 | } |
| 43192 | skip221: ; |
| 43193 | } |
| 43194 | } |
| 43195 | if (verbose) printf(" done\n"); |
| 43196 | cod_free_parse_context(context); |
| 43197 | cod_code_free(gen_code); |
| 43198 | } |
| 43199 | if ((only_run_test == NULL((void*)0)) || |
| 43200 | (strcmp(only_run_test, "d/i") == 0)) { |
| 43201 | int i, j; |
| 43202 | static char code[] = "{\n\ |
| 43203 | double a = p1;\n\ |
| 43204 | int b = p2;\n\ |
| 43205 | return a / b;\n\ |
| 43206 | }"; |
| 43207 | |
| 43208 | double (*proc)(double a, int b); |
| 43209 | cod_parse_context context = new_cod_parse_context(); |
| 43210 | int dumped = 0; |
| 43211 | |
| 43212 | cod_code gen_code; |
| 43213 | |
| 43214 | /* test for double / int */ |
| 43215 | if (verbose) printf("test for double / int"); |
| 43216 | |
| 43217 | cod_assoc_externs(context, externs); |
| 43218 | cod_parse_for_context(extern_string, context); |
| 43219 | |
| 43220 | cod_subroutine_declaration("double proc(double p1, int p2)", |
| 43221 | context); |
| 43222 | gen_code = cod_code_gen(code, context); |
| 43223 | proc = (double (*)(double, int))(long)gen_code->func; |
| 43224 | |
| 43225 | |
| 43226 | for (i=0 ; i < sizeof(src1d_vals)/sizeof(src1d_vals[0]) ; i++) { |
| 43227 | double source1_d = src1d_vals[i]; |
| 43228 | for (j=0 ; j < sizeof(src2i_vals)/sizeof(src2i_vals[0]) ; j++) { |
| 43229 | int source2_i = src2i_vals[j]; |
| 43230 | |
| 43231 | double expected_result; |
| 43232 | double result; |
| 43233 | |
| 43234 | if (source2_i == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip222;} |
| 43235 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 43236 | |
| 43237 | expected_result = (double) (source1_d / source2_i); |
| 43238 | |
| 43239 | result = proc(source1_d, source2_i); |
| 43240 | if (expected_result != result) { |
| 43241 | printf("Failed double / int test, expected %g, got %g, for %g / %d\n", |
| 43242 | expected_result, result, source1_d, source2_i); |
| 43243 | if (dumped == 0) cod_dump(gen_code); |
| 43244 | failed++; |
| 43245 | dumped++; |
| 43246 | } |
| 43247 | skip222: ; |
| 43248 | } |
| 43249 | } |
| 43250 | if (verbose) printf(" done\n"); |
| 43251 | cod_free_parse_context(context); |
| 43252 | cod_code_free(gen_code); |
| 43253 | } |
| 43254 | if ((only_run_test == NULL((void*)0)) || |
| 43255 | (strcmp(only_run_test, "d/u") == 0)) { |
| 43256 | int i, j; |
| 43257 | static char code[] = "{\n\ |
| 43258 | double a = p1;\n\ |
| 43259 | unsigned int b = p2;\n\ |
| 43260 | return a / b;\n\ |
| 43261 | }"; |
| 43262 | |
| 43263 | double (*proc)(double a, unsigned int b); |
| 43264 | cod_parse_context context = new_cod_parse_context(); |
| 43265 | int dumped = 0; |
| 43266 | |
| 43267 | cod_code gen_code; |
| 43268 | |
| 43269 | /* test for double / unsigned int */ |
| 43270 | if (verbose) printf("test for double / unsigned int"); |
| 43271 | |
| 43272 | cod_assoc_externs(context, externs); |
| 43273 | cod_parse_for_context(extern_string, context); |
| 43274 | |
| 43275 | cod_subroutine_declaration("double proc(double p1, unsigned int p2)", |
| 43276 | context); |
| 43277 | gen_code = cod_code_gen(code, context); |
| 43278 | proc = (double (*)(double, unsigned int))(long)gen_code->func; |
| 43279 | |
| 43280 | |
| 43281 | for (i=0 ; i < sizeof(src1d_vals)/sizeof(src1d_vals[0]) ; i++) { |
| 43282 | double source1_d = src1d_vals[i]; |
| 43283 | for (j=0 ; j < sizeof(src2u_vals)/sizeof(src2u_vals[0]) ; j++) { |
| 43284 | unsigned int source2_u = src2u_vals[j]; |
| 43285 | |
| 43286 | double expected_result; |
| 43287 | double result; |
| 43288 | |
| 43289 | if (source2_u == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip223;} |
| 43290 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 43291 | |
| 43292 | expected_result = (double) (source1_d / source2_u); |
| 43293 | |
| 43294 | result = proc(source1_d, source2_u); |
| 43295 | if (expected_result != result) { |
| 43296 | printf("Failed double / unsigned int test, expected %g, got %g, for %g / %u\n", |
| 43297 | expected_result, result, source1_d, source2_u); |
| 43298 | if (dumped == 0) cod_dump(gen_code); |
| 43299 | failed++; |
| 43300 | dumped++; |
| 43301 | } |
| 43302 | skip223: ; |
| 43303 | } |
| 43304 | } |
| 43305 | if (verbose) printf(" done\n"); |
| 43306 | cod_free_parse_context(context); |
| 43307 | cod_code_free(gen_code); |
| 43308 | } |
| 43309 | if ((only_run_test == NULL((void*)0)) || |
| 43310 | (strcmp(only_run_test, "d/ul") == 0)) { |
| 43311 | int i, j; |
| 43312 | static char code[] = "{\n\ |
| 43313 | double a = p1;\n\ |
| 43314 | unsigned long b = p2;\n\ |
| 43315 | return a / b;\n\ |
| 43316 | }"; |
| 43317 | |
| 43318 | double (*proc)(double a, unsigned long b); |
| 43319 | cod_parse_context context = new_cod_parse_context(); |
| 43320 | int dumped = 0; |
| 43321 | |
| 43322 | cod_code gen_code; |
| 43323 | |
| 43324 | /* test for double / unsigned long */ |
| 43325 | if (verbose) printf("test for double / unsigned long"); |
| 43326 | |
| 43327 | cod_assoc_externs(context, externs); |
| 43328 | cod_parse_for_context(extern_string, context); |
| 43329 | |
| 43330 | cod_subroutine_declaration("double proc(double p1, unsigned long p2)", |
| 43331 | context); |
| 43332 | gen_code = cod_code_gen(code, context); |
| 43333 | proc = (double (*)(double, unsigned long))(long)gen_code->func; |
| 43334 | |
| 43335 | |
| 43336 | for (i=0 ; i < sizeof(src1d_vals)/sizeof(src1d_vals[0]) ; i++) { |
| 43337 | double source1_d = src1d_vals[i]; |
| 43338 | for (j=0 ; j < sizeof(src2ul_vals)/sizeof(src2ul_vals[0]) ; j++) { |
| 43339 | unsigned long source2_ul = src2ul_vals[j]; |
| 43340 | |
| 43341 | double expected_result; |
| 43342 | double result; |
| 43343 | |
| 43344 | if (source2_ul == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip224;} |
| 43345 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 43346 | |
| 43347 | expected_result = (double) (source1_d / source2_ul); |
| 43348 | |
| 43349 | result = proc(source1_d, source2_ul); |
| 43350 | if (expected_result != result) { |
| 43351 | printf("Failed double / unsigned long test, expected %g, got %g, for %g / %lu\n", |
| 43352 | expected_result, result, source1_d, source2_ul); |
| 43353 | if (dumped == 0) cod_dump(gen_code); |
| 43354 | failed++; |
| 43355 | dumped++; |
| 43356 | } |
| 43357 | skip224: ; |
| 43358 | } |
| 43359 | } |
| 43360 | if (verbose) printf(" done\n"); |
| 43361 | cod_free_parse_context(context); |
| 43362 | cod_code_free(gen_code); |
| 43363 | } |
| 43364 | if ((only_run_test == NULL((void*)0)) || |
| 43365 | (strcmp(only_run_test, "d/l") == 0)) { |
| 43366 | int i, j; |
| 43367 | static char code[] = "{\n\ |
| 43368 | double a = p1;\n\ |
| 43369 | long b = p2;\n\ |
| 43370 | return a / b;\n\ |
| 43371 | }"; |
| 43372 | |
| 43373 | double (*proc)(double a, long b); |
| 43374 | cod_parse_context context = new_cod_parse_context(); |
| 43375 | int dumped = 0; |
| 43376 | |
| 43377 | cod_code gen_code; |
| 43378 | |
| 43379 | /* test for double / long */ |
| 43380 | if (verbose) printf("test for double / long"); |
| 43381 | |
| 43382 | cod_assoc_externs(context, externs); |
| 43383 | cod_parse_for_context(extern_string, context); |
| 43384 | |
| 43385 | cod_subroutine_declaration("double proc(double p1, long p2)", |
| 43386 | context); |
| 43387 | gen_code = cod_code_gen(code, context); |
| 43388 | proc = (double (*)(double, long))(long)gen_code->func; |
| 43389 | |
| 43390 | |
| 43391 | for (i=0 ; i < sizeof(src1d_vals)/sizeof(src1d_vals[0]) ; i++) { |
| 43392 | double source1_d = src1d_vals[i]; |
| 43393 | for (j=0 ; j < sizeof(src2l_vals)/sizeof(src2l_vals[0]) ; j++) { |
| 43394 | long source2_l = src2l_vals[j]; |
| 43395 | |
| 43396 | double expected_result; |
| 43397 | double result; |
| 43398 | |
| 43399 | if (source2_l == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip225;} |
| 43400 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 43401 | |
| 43402 | expected_result = (double) (source1_d / source2_l); |
| 43403 | |
| 43404 | result = proc(source1_d, source2_l); |
| 43405 | if (expected_result != result) { |
| 43406 | printf("Failed double / long test, expected %g, got %g, for %g / %ld\n", |
| 43407 | expected_result, result, source1_d, source2_l); |
| 43408 | if (dumped == 0) cod_dump(gen_code); |
| 43409 | failed++; |
| 43410 | dumped++; |
| 43411 | } |
| 43412 | skip225: ; |
| 43413 | } |
| 43414 | } |
| 43415 | if (verbose) printf(" done\n"); |
| 43416 | cod_free_parse_context(context); |
| 43417 | cod_code_free(gen_code); |
| 43418 | } |
| 43419 | if ((only_run_test == NULL((void*)0)) || |
| 43420 | (strcmp(only_run_test, "d/f") == 0)) { |
| 43421 | int i, j; |
| 43422 | static char code[] = "{\n\ |
| 43423 | double a = p1;\n\ |
| 43424 | float b = p2;\n\ |
| 43425 | return a / b;\n\ |
| 43426 | }"; |
| 43427 | |
| 43428 | double (*proc)(double a, float b); |
| 43429 | cod_parse_context context = new_cod_parse_context(); |
| 43430 | int dumped = 0; |
| 43431 | |
| 43432 | cod_code gen_code; |
| 43433 | |
| 43434 | /* test for double / float */ |
| 43435 | if (verbose) printf("test for double / float"); |
| 43436 | |
| 43437 | cod_assoc_externs(context, externs); |
| 43438 | cod_parse_for_context(extern_string, context); |
| 43439 | |
| 43440 | cod_subroutine_declaration("double proc(double p1, float p2)", |
| 43441 | context); |
| 43442 | gen_code = cod_code_gen(code, context); |
| 43443 | proc = (double (*)(double, float))(long)gen_code->func; |
| 43444 | |
| 43445 | |
| 43446 | for (i=0 ; i < sizeof(src1d_vals)/sizeof(src1d_vals[0]) ; i++) { |
| 43447 | double source1_d = src1d_vals[i]; |
| 43448 | for (j=0 ; j < sizeof(src2f_vals)/sizeof(src2f_vals[0]) ; j++) { |
| 43449 | float source2_f = src2f_vals[j]; |
| 43450 | double range = 0.000001 * (fabs((double)source1_d / (double)source2_f)); |
| 43451 | double expected_result; |
| 43452 | double result; |
| 43453 | |
| 43454 | if (source2_f == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip226;} |
| 43455 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 43456 | |
| 43457 | expected_result = (double) (source1_d / source2_f); |
| 43458 | |
| 43459 | result = proc(source1_d, source2_f); |
| 43460 | range += 1.0; |
| 43461 | if ((result > (expected_result + range)) || (result < (expected_result - range))) { |
| 43462 | printf("Failed double / float test, expected %g, got %g, for %g / %g\n", |
| 43463 | expected_result, result, source1_d, source2_f); |
| 43464 | if (dumped == 0) cod_dump(gen_code); |
| 43465 | failed++; |
| 43466 | dumped++; |
| 43467 | } |
| 43468 | skip226: ; |
| 43469 | } |
| 43470 | } |
| 43471 | if (verbose) printf(" done\n"); |
| 43472 | cod_free_parse_context(context); |
| 43473 | cod_code_free(gen_code); |
| 43474 | } |
| 43475 | if ((only_run_test == NULL((void*)0)) || |
| 43476 | (strcmp(only_run_test, "d/d") == 0)) { |
| 43477 | int i, j; |
| 43478 | static char code[] = "{\n\ |
| 43479 | double a = p1;\n\ |
| 43480 | double b = p2;\n\ |
| 43481 | return a / b;\n\ |
| 43482 | }"; |
| 43483 | |
| 43484 | double (*proc)(double a, double b); |
| 43485 | cod_parse_context context = new_cod_parse_context(); |
| 43486 | int dumped = 0; |
| 43487 | |
| 43488 | cod_code gen_code; |
| 43489 | |
| 43490 | /* test for double / double */ |
| 43491 | if (verbose) printf("test for double / double"); |
| 43492 | |
| 43493 | cod_assoc_externs(context, externs); |
| 43494 | cod_parse_for_context(extern_string, context); |
| 43495 | |
| 43496 | cod_subroutine_declaration("double proc(double p1, double p2)", |
| 43497 | context); |
| 43498 | gen_code = cod_code_gen(code, context); |
| 43499 | proc = (double (*)(double, double))(long)gen_code->func; |
| 43500 | |
| 43501 | |
| 43502 | for (i=0 ; i < sizeof(src1d_vals)/sizeof(src1d_vals[0]) ; i++) { |
| 43503 | double source1_d = src1d_vals[i]; |
| 43504 | for (j=0 ; j < sizeof(src2d_vals)/sizeof(src2d_vals[0]) ; j++) { |
| 43505 | double source2_d = src2d_vals[j]; |
| 43506 | |
| 43507 | double expected_result; |
| 43508 | double result; |
| 43509 | |
| 43510 | if (source2_d == 0) {if (verbose) {printf("+");fflush(stdoutstdout);} goto skip227;} |
| 43511 | if (verbose) {printf(".");fflush(stdoutstdout);} |
| 43512 | |
| 43513 | expected_result = (double) (source1_d / source2_d); |
| 43514 | |
| 43515 | result = proc(source1_d, source2_d); |
| 43516 | if (expected_result != result) { |
| 43517 | printf("Failed double / double test, expected %g, got %g, for %g / %g\n", |
| 43518 | expected_result, result, source1_d, source2_d); |
| 43519 | if (dumped == 0) cod_dump(gen_code); |
| 43520 | failed++; |
| 43521 | dumped++; |
| 43522 | } |
| 43523 | skip227: ; |
| 43524 | } |
| 43525 | } |
| 43526 | if (verbose) printf(" done\n"); |
| 43527 | cod_free_parse_context(context); |
| 43528 | cod_code_free(gen_code); |
| 43529 | } |
| 43530 | } |
| 43531 | |
| 43532 | int |
| 43533 | main(int argc, char **argv) |
| 43534 | { |
| 43535 | int i = 1; |
| 43536 | |
| 43537 | initialize_values(); |
| 43538 | |
| 43539 | while (i < argc) { |
| 43540 | if (strcmp(argv[i], "-v") == 0) { |
| 43541 | verbose++; |
| 43542 | } else { |
| 43543 | printf("Only running test \"%s\"\n", argv[i]); |
| 43544 | only_run_test = argv[i]; |
| 43545 | } |
| 43546 | i++; |
| 43547 | } |
| 43548 | |
| 43549 | |
| 43550 | mod_c_tests(); |
| 43551 | |
| 43552 | mod_uc_tests(); |
| 43553 | |
| 43554 | mod_s_tests(); |
| 43555 | |
| 43556 | mod_us_tests(); |
| 43557 | |
| 43558 | mod_i_tests(); |
| 43559 | |
| 43560 | mod_u_tests(); |
| 43561 | |
| 43562 | mod_ul_tests(); |
| 43563 | |
| 43564 | mod_l_tests(); |
| 43565 | |
| 43566 | and_c_tests(); |
| 43567 | |
| 43568 | and_uc_tests(); |
| 43569 | |
| 43570 | and_s_tests(); |
| 43571 | |
| 43572 | and_us_tests(); |
| 43573 | |
| 43574 | and_i_tests(); |
| 43575 | |
| 43576 | and_u_tests(); |
| 43577 | |
| 43578 | and_ul_tests(); |
| 43579 | |
| 43580 | and_l_tests(); |
| 43581 | |
| 43582 | or_c_tests(); |
| 43583 | |
| 43584 | or_uc_tests(); |
| 43585 | |
| 43586 | or_s_tests(); |
| 43587 | |
| 43588 | or_us_tests(); |
| 43589 | |
| 43590 | or_i_tests(); |
| 43591 | |
| 43592 | or_u_tests(); |
| 43593 | |
| 43594 | or_ul_tests(); |
| 43595 | |
| 43596 | or_l_tests(); |
| 43597 | |
| 43598 | not_c_tests(); |
| 43599 | |
| 43600 | not_uc_tests(); |
| 43601 | |
| 43602 | not_s_tests(); |
| 43603 | |
| 43604 | not_us_tests(); |
| 43605 | |
| 43606 | not_i_tests(); |
| 43607 | |
| 43608 | not_u_tests(); |
| 43609 | |
| 43610 | not_ul_tests(); |
| 43611 | |
| 43612 | not_l_tests(); |
| 43613 | |
| 43614 | lsh_c_tests(); |
| 43615 | |
| 43616 | lsh_uc_tests(); |
| 43617 | |
| 43618 | lsh_s_tests(); |
| 43619 | |
| 43620 | lsh_us_tests(); |
| 43621 | |
| 43622 | lsh_i_tests(); |
| 43623 | |
| 43624 | lsh_u_tests(); |
| 43625 | |
| 43626 | lsh_ul_tests(); |
| 43627 | |
| 43628 | lsh_l_tests(); |
| 43629 | |
| 43630 | rsh_c_tests(); |
| 43631 | |
| 43632 | rsh_uc_tests(); |
| 43633 | |
| 43634 | rsh_s_tests(); |
| 43635 | |
| 43636 | rsh_us_tests(); |
| 43637 | |
| 43638 | rsh_i_tests(); |
| 43639 | |
| 43640 | rsh_u_tests(); |
| 43641 | |
| 43642 | rsh_ul_tests(); |
| 43643 | |
| 43644 | rsh_l_tests(); |
| 43645 | |
| 43646 | add_c_tests(); |
| 43647 | |
| 43648 | add_uc_tests(); |
| 43649 | |
| 43650 | add_s_tests(); |
| 43651 | |
| 43652 | add_us_tests(); |
| 43653 | |
| 43654 | add_i_tests(); |
| 43655 | |
| 43656 | add_u_tests(); |
| 43657 | |
| 43658 | add_ul_tests(); |
| 43659 | |
| 43660 | add_l_tests(); |
| 43661 | |
| 43662 | add_f_tests(); |
| 43663 | |
| 43664 | add_d_tests(); |
| 43665 | |
| 43666 | sub_c_tests(); |
| 43667 | |
| 43668 | sub_uc_tests(); |
| 43669 | |
| 43670 | sub_s_tests(); |
| 43671 | |
| 43672 | sub_us_tests(); |
| 43673 | |
| 43674 | sub_i_tests(); |
| 43675 | |
| 43676 | sub_u_tests(); |
| 43677 | |
| 43678 | sub_ul_tests(); |
| 43679 | |
| 43680 | sub_l_tests(); |
| 43681 | |
| 43682 | sub_f_tests(); |
| 43683 | |
| 43684 | sub_d_tests(); |
| 43685 | |
| 43686 | mult_c_tests(); |
| 43687 | |
| 43688 | mult_uc_tests(); |
| 43689 | |
| 43690 | mult_s_tests(); |
| 43691 | |
| 43692 | mult_us_tests(); |
| 43693 | |
| 43694 | mult_i_tests(); |
| 43695 | |
| 43696 | mult_u_tests(); |
| 43697 | |
| 43698 | mult_ul_tests(); |
| 43699 | |
| 43700 | mult_l_tests(); |
| 43701 | |
| 43702 | mult_f_tests(); |
| 43703 | |
| 43704 | mult_d_tests(); |
| 43705 | |
| 43706 | div_c_tests(); |
| 43707 | |
| 43708 | div_uc_tests(); |
| 43709 | |
| 43710 | div_s_tests(); |
| 43711 | |
| 43712 | div_us_tests(); |
| 43713 | |
| 43714 | div_i_tests(); |
| 43715 | |
| 43716 | div_u_tests(); |
| 43717 | |
| 43718 | div_ul_tests(); |
| 43719 | |
| 43720 | div_l_tests(); |
| 43721 | |
| 43722 | div_f_tests(); |
| 43723 | |
| 43724 | div_d_tests(); |
| 43725 | |
| 43726 | return failed; |
| 43727 | } |